Java源码示例:android.transition.AutoTransition
示例1
/**
* 模拟入场动画
*/
private void runEnterAnim() {
getScreenSize();
mIvCover.post(new Runnable() {
@Override public void run() {
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(mScreenWidth, mScreenHeight);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ChangeImageTransform changeImageTransform = new ChangeImageTransform();
AutoTransition autoTransition = new AutoTransition();
changeImageTransform.setDuration(TRANSITIONS_DURATION);
autoTransition.setDuration(TRANSITIONS_DURATION);
TransitionSet transitionSet = new TransitionSet();
transitionSet.addTransition(autoTransition);
transitionSet.addTransition(changeImageTransform);
TransitionManager.beginDelayedTransition(mTransitionsContainer, transitionSet);
mIvCover.setLayoutParams(params);
mIvCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
} else {
mIvCover.setLayoutParams(params);
mIvCover.setScaleType(ImageView.ScaleType.CENTER_CROP);
}
}
});
}
示例2
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void initWindowTransitions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
AutoTransition transition = new AutoTransition();
getWindow().setSharedElementEnterTransition(transition);
getWindow().setSharedElementExitTransition(transition);
ActivityCompat.setEnterSharedElementCallback(this, new SharedElementCallback() {
@Override public void onSharedElementEnd(List<String> sharedElementNames,
List<View> sharedElements, List<View> sharedElementSnapshots) {
for (final View view : sharedElements) {
if (view instanceof PhotoDraweeView) {
((PhotoDraweeView) view).setScale(1f, true);
}
}
}
});
}
}
示例3
private void initTransition() {
Window window = getWindow();
TransitionSet set = new TransitionSet();
AutoTransition autoTransition = new AutoTransition();
autoTransition.excludeTarget(R.id.ic_head, true);
autoTransition.addTarget(R.id.tx_name);
autoTransition.addTarget(R.id.ic_location);
autoTransition.addTarget(R.id.tx_location);
autoTransition.setDuration(600);
autoTransition.setInterpolator(new DecelerateInterpolator());
set.addTransition(autoTransition);
BezierTransition bezierTransition = new BezierTransition();
bezierTransition.addTarget(R.id.ic_head);
bezierTransition.excludeTarget(R.id.tx_name, true);
bezierTransition.excludeTarget(R.id.ic_location, true);
bezierTransition.excludeTarget(R.id.tx_location, true);
bezierTransition.setDuration(600);
bezierTransition.setInterpolator(new DecelerateInterpolator());
set.addTransition(bezierTransition);
CircularRevealTransition transition = new CircularRevealTransition();
transition.excludeTarget(android.R.id.statusBarBackground, true);
window.setEnterTransition(transition);
window.setReenterTransition(transition);
window.setReturnTransition(transition);
window.setExitTransition(transition);
window.setSharedElementEnterTransition(set);
window.setSharedElementReturnTransition(set);
}
示例4
BottomNavigationAnimationHelperKitkat() {
mSet = new AutoTransition();
mSet.setOrdering(TransitionSet.ORDERING_TOGETHER);
mSet.setDuration(ACTIVE_ANIMATION_DURATION_MS);
mSet.setInterpolator(new FastOutSlowInInterpolator());
TextScale textScale = new TextScale();
mSet.addTransition(textScale);
}
示例5
public DribbbleCommentsAdapter(Context context, int resource, List<Comment> comments) {
super(context, resource, comments);
inflater = LayoutInflater.from(context);
if (UI.isLollipop()) {
change = new AutoTransition();
change.setDuration(200L);
change.setInterpolator(AnimationUtils.loadInterpolator(context,
android.R.interpolator.fast_out_slow_in));
}
}
示例6
@SuppressWarnings("unused")
@OnClick(R.id.image_avatar)
protected void onChangeCheese() {
int iconRes = Cheeses.getRandomCheeseDrawable();
String titleString = Cheeses.getRandomCheeseString();
TransitionManager.beginDelayedTransition(layoutContainer, new AutoTransition());
imageAvatar.setImageResource(iconRes);
textTitle.setText(titleString);
colorize(((BitmapDrawable) imageAvatar.getDrawable()).getBitmap());
}
示例7
/**
* Creates a AutoTransition that calls the {@linkplain android.transition.Transition.TransitionListener#onTransitionEnd(Transition)}
* of the passing Listener when complete
*/
public static Transition withAction(TransitionListener finishingAction) {
AutoTransition transition = new AutoTransition();
transition.setDuration(FADE_OUT_DURATION);
transition.addListener(finishingAction);
return transition;
}
示例8
public static Transition createTransition() {
AutoTransition transition = new AutoTransition();
transition.setDuration(FADE_IN_DURATION);
return transition;
}
示例9
static Object createAutoTransition() {
return new AutoTransition();
}