android.transition.Transition类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中android.transition.Transition类的一些代码示例,展示了Transition类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transition类的具体详情如下:
包路径:android.transition.Transition
类名称:Transition

Transition介绍

暂无

代码示例

代码示例来源:origin: bluelinelabs/Conductor

private void scheduleRemoveTargets(@NonNull final Transition overallTransition,
                  @Nullable final Transition enterTransition, @Nullable final List<View> enteringViews,
                  @Nullable final Transition exitTransition, @Nullable final List<View> exitingViews,
                  @Nullable final Transition sharedElementTransition, @Nullable final List<View> toSharedElements) {
  overallTransition.addListener(new TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
      if (enterTransition != null && enteringViews != null) {
        TransitionUtils.replaceTargets(enterTransition, enteringViews, null);
      }
      if (exitTransition != null && exitingViews != null) {
        TransitionUtils.replaceTargets(exitTransition, exitingViews, null);
      }
      if (sharedElementTransition != null && toSharedElements != null) {
        TransitionUtils.replaceTargets(sharedElementTransition, toSharedElements, null);
      }
    }
    @Override
    public void onTransitionEnd(Transition transition) { }
    @Override
    public void onTransitionCancel(Transition transition) { }
    @Override
    public void onTransitionPause(Transition transition) { }
    @Override
    public void onTransitionResume(Transition transition) { }
  });
}

代码示例来源:origin: fanrunqi/MaterialLogin

@Override
public void onTransitionEnd(Transition transition) {
  transition.removeListener(this);
  animateRevealShow();
}

代码示例来源:origin: bluelinelabs/Conductor

@Override @NonNull
protected Transition getTransition(@NonNull final ViewGroup container, @Nullable final View from, @Nullable final View to, boolean isPush) {
  Transition backgroundFade = new Fade();
  backgroundFade.addTarget(R.id.dialog_background);
  Transition fabTransform = new FabTransform(ContextCompat.getColor(container.getContext(), R.color.colorAccent), R.drawable.ic_github_face);
  TransitionSet set = new TransitionSet();
  set.addTransition(backgroundFade);
  set.addTransition(fabTransform);
  return set;
}

代码示例来源:origin: bluelinelabs/Conductor

public static void replaceTargets(@NonNull Transition transition, @NonNull List<View> oldTargets, @Nullable List<View> newTargets) {
  if (transition instanceof TransitionSet) {
    TransitionSet set = (TransitionSet) transition;
    int numTransitions = set.getTransitionCount();
    for (int i = 0; i < numTransitions; i++) {
      Transition child = set.getTransitionAt(i);
      replaceTargets(child, oldTargets, newTargets);
    }
  } else if (!TransitionUtils.hasSimpleTarget(transition)) {
    List<View> targets = transition.getTargets();
    if (targets != null && targets.size() == oldTargets.size() && targets.containsAll(oldTargets)) {
      final int targetCount = newTargets == null ? 0 : newTargets.size();
      for (int i = 0; i < targetCount; i++) {
        transition.addTarget(newTargets.get(i));
      }
      for (int i = oldTargets.size() - 1; i >= 0; i--) {
        transition.removeTarget(oldTargets.get(i));
      }
    }
  }
}

代码示例来源:origin: bluelinelabs/Conductor

public static void addTargets(@Nullable Transition transition, @NonNull List<View> views) {
  if (transition == null) {
    return;
  }
  if (transition instanceof TransitionSet) {
    TransitionSet set = (TransitionSet) transition;
    int numTransitions = set.getTransitionCount();
    for (int i = 0; i < numTransitions; i++) {
      Transition child = set.getTransitionAt(i);
      addTargets(child, views);
    }
  } else if (!hasSimpleTarget(transition)) {
    List<View> targets = transition.getTargets();
    if (isNullOrEmpty(targets)) {
      int numViews = views.size();
      for (int i = 0; i < numViews; i++) {
        transition.addTarget(views.get(i));
      }
    }
  }
}

代码示例来源:origin: bluelinelabs/Conductor

@Nullable
@Override
public Transition getSharedElementTransition(@NonNull ViewGroup container, @Nullable final View from, @Nullable View to, boolean isPush) {
  Transition transition = new TransitionSet().addTransition(new ChangeBounds()).addTransition(new ChangeClipBounds()).addTransition(new ChangeTransform());
  transition.setPathMotion(new ArcMotion());
  // The framework doesn't totally fade out the "from" shared element, so we'll hide it manually once it's safe.
  transition.addListener(new TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
      if (from != null) {
        for (String name : sharedElementNames) {
          View namedView = TransitionUtils.findNamedView(from, name);
          if (namedView != null) {
            namedView.setVisibility(View.INVISIBLE);
          }
        }
      }
    }
    @Override
    public void onTransitionEnd(Transition transition) { }
    @Override
    public void onTransitionCancel(Transition transition) { }
    @Override
    public void onTransitionPause(Transition transition) { }
    @Override
    public void onTransitionResume(Transition transition) { }
  });
  return transition;
}

代码示例来源:origin: vipulyaara/betterHotels

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setupEnterAnimation() {
  Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.change_bounds_with_arc);
  transition.setDuration(300);
  getWindow().setSharedElementEnterTransition(transition);
  transition.addListener(new Transition.TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
    }
    @Override
    public void onTransitionEnd(Transition transition) {
    }
    @Override
    public void onTransitionCancel(Transition transition) {
    }
    @Override
    public void onTransitionPause(Transition transition) {
    }
    @Override
    public void onTransitionResume(Transition transition) {
    }
  });
}

代码示例来源:origin: andremion/Music-Cover-View

mRectToCircleTransition.addTarget(this);
mRectToCircleTransition.addListener(new TransitionAdapter() {
  @Override
  public void onTransitionStart(Transition transition) {
mCircleToRectTransition.addTarget(this);
mCircleToRectTransition.addListener(new TransitionAdapter() {
  @Override
  public void onTransitionStart(Transition transition) {

代码示例来源:origin: tcking/GiraffePlayer2

transition.setStartDelay(200);
transition.addListener(new Transition.TransitionListener() {

代码示例来源:origin: jonasbleyl/recurrence

public void setupTransitions() {
  // Add shared element transition animation if on Lollipop or later
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    // Enter transitions
    TransitionSet setEnter = new TransitionSet();
    Transition slideDown = new Explode();
    slideDown.addTarget(headerView);
    slideDown.excludeTarget(scrollView, true);
    slideDown.setDuration(500);
    setEnter.addTransition(slideDown);
    Transition fadeOut = new Slide(Gravity.BOTTOM);
    fadeOut.addTarget(scrollView);
    fadeOut.setDuration(500);
    setEnter.addTransition(fadeOut);
    // Exit transitions
    TransitionSet setExit = new TransitionSet();
    Transition slideDown2 = new Explode();
    slideDown2.addTarget(headerView);
    slideDown2.setDuration(570);
    setExit.addTransition(slideDown2);
    Transition fadeOut2 = new Slide(Gravity.BOTTOM);
    fadeOut2.addTarget(scrollView);
    fadeOut2.setDuration(280);
    setExit.addTransition(fadeOut2);
    getWindow().setEnterTransition(setEnter);
    getWindow().setReturnTransition(setExit);
  }
}

代码示例来源:origin: DroidsOnRoids/Workcation

public TransitionBuilder duration(long duration) {
  transition.setDuration(duration);
  return this;
}

代码示例来源:origin: stackoverflow.com

// above I've gotten the sharedElements (Views)...
     newSharedElement.setTransitionName("sharedProperty");
     oldSharedElement.setTransitionName("sharedProperty");
     // having android:transitionName in the xml can be easier
     // This transition handles the shared element move based on the shared tansition name
     Transition shared = TransitionInflater.from(context).inflateTransition(android.R.transition.move);
     shared.addTarget(newSharedElement);
     // create a scene container is a parentView (FrameLayout) of both children
     Scene scene = new Scene(container, newChild);
     // everything else is set to Fade, shared element is excluded
     Transition fade = TransitionInflater.from(context).inflateTransition(android.R.transition.fade);
     fade.excludeTarget(newSharedElement, true);
     // combine the translations
     TransitionSet set = new TransitionSet();
     set.addTransition(shared).addTransition(fade);
     // translationize
     TransitionManager.go(scene, set);

代码示例来源:origin: jonasbleyl/recurrence

@Override
  public void onClick(View view) {
    Intent intent = new Intent(context, ViewActivity.class);
    intent.putExtra("NOTIFICATION_ID", reminderList.get(viewHolder.getAdapterPosition()).getId());
    // Add shared element transition animation if on Lollipop or later
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      CardView cardView = (CardView) view.findViewById(R.id.notification_card);
      TransitionSet setExit = new TransitionSet();
      Transition transition = new Fade();
      transition.excludeTarget(android.R.id.statusBarBackground, true);
      transition.excludeTarget(android.R.id.navigationBarBackground, true);
      transition.excludeTarget(R.id.fab_button, true);
      transition.excludeTarget(R.id.recycler_view, true);
      transition.setDuration(400);
      setExit.addTransition(transition);
      ((Activity) context).getWindow().setSharedElementsUseOverlay(false);
      ((Activity) context).getWindow().setReenterTransition(null);
      ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(((Activity) context), cardView, "cardTransition");
      ActivityCompat.startActivity(((Activity) context), intent, options.toBundle());
      ((RecyclerListener) context).hideFab();
    } else {
      context.startActivity(intent);
    }
  }
});

代码示例来源:origin: stackoverflow.com

Transition ts = new Explode();  //Slide(); //Explode();
ts.setStartDelay(2000);
ts.setDuration(5000);

代码示例来源:origin: DroidsOnRoids/Workcation

public TransitionBuilder excludeTarget(final View view, final boolean exclude){
  transition.excludeTarget(view, exclude);
  return this;
}

代码示例来源:origin: vipulyaara/betterHotels

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setupEnterAnimation() {
  Transition transition = TransitionInflater.from(this).inflateTransition(R.transition.change_bounds_with_arc);
  transition.setDuration(300);
  getWindow().setSharedElementEnterTransition(transition);
  transition.addListener(new Transition.TransitionListener() {
    @Override
    public void onTransitionStart(Transition transition) {
    }
    @Override
    public void onTransitionEnd(Transition transition) {
    }
    @Override
    public void onTransitionCancel(Transition transition) {
    }
    @Override
    public void onTransitionPause(Transition transition) {
    }
    @Override
    public void onTransitionResume(Transition transition) {
    }
  });
}

代码示例来源:origin: blundell/QuickSand

public void setDuration(long duration) {
  transition.setDuration(duration);
}

代码示例来源:origin: codeka/wwmmo

for (SharedViews.SharedView sharedView : sharedViews.getSharedViews()) {
 if (sharedView.getViewId() != 0) {
  fadeTransition.excludeTarget(sharedView.getViewId(), true);
  transformTransition.addTarget(sharedView.getViewId());
 } else {
  String name = "shared-" + Long.toString(RANDOM.nextLong());
   log.error("Unexpected SharedView configuration.");
  fadeTransition.excludeTarget(name, true);
  transformTransition.addTarget(name);

代码示例来源:origin: DroidsOnRoids/Workcation

public TransitionBuilder excludeTarget(final String targetName, final boolean exclude) {
  transition.excludeTarget(targetName, exclude);
  return this;
}

代码示例来源:origin: CarGuo/GSYVideoPlayer

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private boolean addTransitionListener() {
  transition = getWindow().getSharedElementEnterTransition();
  if (transition != null) {
    transition.addListener(new OnTransitionListener(){
      @Override
      public void onTransitionEnd(Transition transition) {
        super.onTransitionEnd(transition);
        videoPlayer.startPlayLogic();
        transition.removeListener(this);
      }
    });
    return true;
  }
  return false;
}

相关文章