当前位置: 首页>>代码示例>>Java>>正文


Java Transition.setDuration方法代码示例

本文整理汇总了Java中android.transition.Transition.setDuration方法的典型用法代码示例。如果您正苦于以下问题:Java Transition.setDuration方法的具体用法?Java Transition.setDuration怎么用?Java Transition.setDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.transition.Transition的用法示例。


在下文中一共展示了Transition.setDuration方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSlideAnimation

import android.transition.Transition; //导入方法依赖的package包/类
@SuppressLint("RtlHardcoded")
private TransitionAnimation createSlideAnimation(boolean forward, AnimationData animationData) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		Transition enterTransition = forward ? new Slide(Gravity.RIGHT) : new Slide(Gravity.LEFT);
		Transition exitTransition = forward ? new Slide(Gravity.LEFT) : new Slide(Gravity.RIGHT);
		LollipopTransitionAnimation animation = new LollipopTransitionAnimation(enterTransition, exitTransition);
		animation.setAllowEnterTransitionOverlap(false);

		Fragment currentFragment = mActivity.getSupportFragmentManager().findFragmentById(R.id.fragment_container);
		if (currentFragment instanceof SharedElementProvider) {
			SharedElementProvider sharedElementProvider = (SharedElementProvider) currentFragment;
			View sharedElement = sharedElementProvider.getSharedElement(animationData);
			String shareElementName = sharedElementProvider.getSharedElementName(animationData);
			animation.addSharedElement(sharedElement, shareElementName);
			Transition moveTransition = TransitionInflater.from(mActivity).inflateTransition(android.R.transition.move);
			moveTransition.setDuration(600);
			animation.setSharedElementTransition(moveTransition);
		}
		return animation;
	} else {
		int enterAnimRes = forward ? R.anim.slide_in_right : R.anim.slide_in_left;
		int exitAnimRes = forward ? R.anim.slide_out_left : R.anim.slide_out_right;
		return new SimpleTransitionAnimation(enterAnimRes, exitAnimRes);
	}
}
 
开发者ID:aartikov,项目名称:Alligator,代码行数:26,代码来源:SampleTransitionAnimationProvider.java

示例2: setupTransitions

import android.transition.Transition; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:35,代码来源:ViewActivity.java


注:本文中的android.transition.Transition.setDuration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。