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


Java TranslateAnimation.setDuration方法代码示例

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


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

示例1: translateAlphaFinishAnimation

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
/**
 * 结束时的动画 平移到底部
 */
public static Animation translateAlphaFinishAnimation() {
    TranslateAnimation translateAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0f,
            Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 1f);
    AlphaAnimation alphaAnimation = new AlphaAnimation(1, 0);
    setDefaultConfig(translateAnimation, true);
    setDefaultConfig(alphaAnimation, true);

    translateAnimation.setDuration(DEFAULT_DIALOG_FINISH_ANIM_TIME);
    alphaAnimation.setDuration(DEFAULT_DIALOG_FINISH_ANIM_TIME);

    AnimationSet animationSet = new AnimationSet(false);
    animationSet.addAnimation(alphaAnimation);
    animationSet.addAnimation(translateAnimation);
    return animationSet;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:19,代码来源:AnimUtil.java

示例2: recoverLayout

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
/** 
 * 位置还原 
 */  
private void recoverLayout() {  
  
    if (!isMoved) {  
        return;//如果没有移动布局,则跳过执行  
    }  
      
    for (int i = 0; i < mMoveViews.size(); i++) {  
        if (mMoveRects.get(i) != null) {
            TranslateAnimation anims = new TranslateAnimation(0, 0, mMoveViews.get(i).getTop(), mMoveRects.get(i).top);
            anims.setDuration(ANIM_TIME);
            mMoveViews.get(i).startAnimation(anims);
            mMoveViews.get(i).layout(mMoveRects.get(i).left, mMoveRects.get(i).top, mMoveRects.get(i).right, mMoveRects.get(i).bottom);

        }  
  
    }
    TranslateAnimation anim = new TranslateAnimation(0, 0, childView.getTop() - originalRect.top, 0);
    anim.setDuration(ANIM_TIME);
    childView.startAnimation(anim);

    childView.layout(originalRect.left, originalRect.top, originalRect.right, originalRect.bottom);

    isMoved = false;

}
 
开发者ID:guzhigang001,项目名称:Bailan,代码行数:29,代码来源:PullRecyclerViewGroup.java

示例3: dispatchTouchEvent

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
	int act = event.getAction();
	if ((act == MotionEvent.ACTION_UP || act == MotionEvent.ACTION_CANCEL)
	&& outBound) {
	outBound = false;
	// scroll back
	}
	if (!lisGestureDetector.onTouchEvent(event)) {
		outBound = false;
	} else {
		outBound = true;
	}
	Rect rect = new Rect();  
       getLocalVisibleRect(rect);  
       TranslateAnimation am = new TranslateAnimation( 0, 0, -rect.top, 0);  
       am.setDuration(300);  
       startAnimation(am);  
       scrollTo(0, 0);
	return super.dispatchTouchEvent(event);
}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:22,代码来源:PullDownListview.java

示例4: getTranslateAnimation

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
/**
 * 位移 Translate
 */
public static Animation getTranslateAnimation(float fromXDelta,
                                              float toXDelta, float fromYDelta, float toYDelta,
                                              long durationMillis) {
    TranslateAnimation translate = new TranslateAnimation(fromXDelta,
            toXDelta, fromYDelta, toYDelta);
    translate.setDuration(durationMillis);
    translate.setFillAfter(true);
    return translate;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:13,代码来源:KJAnimations.java

示例5: initShowAnimation

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
@Override
protected Animation initShowAnimation() {
    TranslateAnimation translateAnimation = new TranslateAnimation(0f, 0f, -DimensUtils.dipToPx(getContext(), 350f), 0);
    translateAnimation.setDuration(450);
    translateAnimation.setInterpolator(new OvershootInterpolator(1));
    return translateAnimation;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:SlideFromTopPopup.java

示例6: createTranslationOutAnimation

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
private Animation createTranslationOutAnimation() {
    int type = TranslateAnimation.RELATIVE_TO_SELF;
    TranslateAnimation an = new TranslateAnimation(type, 0, type, 0, type, 0, type, 1);
    an.setDuration(TRANSLATE_DURATION);
    an.setFillAfter(true);
    return an;
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:8,代码来源:ActionSheet.java

示例7: initAnims

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
private void initAnims() {
	animShow = new TranslateAnimation(
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 1,
			Animation.RELATIVE_TO_SELF, 0);
	animShow.setDuration(300);

	animHide = new TranslateAnimation(
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 0,
			Animation.RELATIVE_TO_SELF, 1);
	animHide.setDuration(300);
}
 
开发者ID:6ag,项目名称:LiuAGeAndroid,代码行数:16,代码来源:PlatformPage.java

示例8: reset

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
private void reset() {
  tracking = false;
  TranslateAnimation a =
    new TranslateAnimation(slide.getLeft(), getLeft(), 0, 0);
  a.setDuration(SLIP_MS);
  a.setInterpolator(new DecelerateInterpolator(SLIP_ACCEL));
  slide.startAnimation(a);
  slide.offsetLeftAndRight(getLeft() - slide.getLeft());
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:10,代码来源:Slider.java

示例9: runPullShadeAnimation

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
AnimationSequence runPullShadeAnimation(final View view) {
    view.setVisibility(View.VISIBLE);
    view.setAlpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    view.setTranslationY(0.0f);
    AnimationSequence sequence = new AnimationSequence();
    sequence.setView(view);
    sequence.setRepeat(true);
    AlphaAnimation fadeIn = new AlphaAnimation(0.0f, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    fadeIn.setDuration(300);
    sequence.addAnimation(fadeIn);
    TranslateAnimation swipe = new TranslateAnimation(0.0f, 0.0f, 0.0f, 100.0f);
    swipe.setDuration(500);
    sequence.addAnimation(swipe);
    Animation fadeOut = new AlphaAnimation(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT, 0.0f);
    fadeOut.setDuration(300);
    sequence.addAnimation(new Runnable() {
        public void run() {
            view.setTranslationY(100.0f);
        }
    }, fadeOut);
    Animation pause = new AlphaAnimation(0.0f, 0.0f);
    pause.setDuration(4000);
    sequence.addAnimation(pause, new Runnable() {
        public void run() {
            view.setTranslationY(0.0f);
        }
    });
    sequence.start();
    return sequence;
}
 
开发者ID:bunnyblue,项目名称:NoticeDog,代码行数:31,代码来源:OOBTutorialActivity.java

示例10: showHelpOverlay

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
private void showHelpOverlay() {
    if (animationsInProgress) return;
    animationsInProgress = true;
    titleLayout.bringToFront();
    helpLayout.setVisibility(View.VISIBLE);

    Animator showAnimation;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        showAnimation = ViewAnimationUtils.createCircularReveal(helpLayout, titleBtnHelpCenterX, titleBtnHelpCenterY, 0, screenDiagonalPx);
    } else {
        showAnimation = ObjectAnimator.ofFloat(helpLayout, "alpha", 0f, 1f);
    }
    showAnimation.setInterpolator(new AccelerateInterpolator());
    showAnimation.setDuration(250);
    showAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mainLayout.setVisibility(View.GONE);
            animationsInProgress = false;
            helpLayoutShown = true;
        }
    });
    showAnimation.start();

    int textMoveOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, getResources().getDisplayMetrics());

    AnimationSet helpHeaderAnimationSet = new AnimationSet(true);
    helpHeaderAnimationSet.addAnimation(new TranslateAnimation(0, 0, textMoveOffset, 0));
    helpHeaderAnimationSet.addAnimation(new AlphaAnimation(0, 1f));
    helpHeaderAnimationSet.setInterpolator(new DecelerateInterpolator());
    helpHeaderAnimationSet.setStartOffset(200);
    helpHeaderAnimationSet.setDuration(450);
    helpLayoutTextHeader.startAnimation(helpHeaderAnimationSet);

    AnimationSet helpContentAnimationSet = new AnimationSet(true);
    helpContentAnimationSet.addAnimation(new TranslateAnimation(0, 0, textMoveOffset, 0));
    helpContentAnimationSet.addAnimation(new AlphaAnimation(0, 1f));
    helpContentAnimationSet.setInterpolator(new DecelerateInterpolator());
    helpContentAnimationSet.setStartOffset(300);
    helpContentAnimationSet.setDuration(450);
    helpLayoutTextContent.startAnimation(helpContentAnimationSet);

    int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 65, getResources().getDisplayMetrics());
    TranslateAnimation helpLayoutBottomPanelSlideUp = new TranslateAnimation(0, 0, height, 0);
    helpLayoutBottomPanelSlideUp.setDuration(550);
    helpLayoutBottomPanelSlideUp.setStartOffset(500);
    helpLayoutBottomPanelSlideUp.setInterpolator(new DecelerateInterpolator());

    helpLayoutBottomPanel.startAnimation(helpLayoutBottomPanelSlideUp);
}
 
开发者ID:Ramotion,项目名称:showroom-android,代码行数:51,代码来源:ShowroomActivity.java

示例11: dispatchTouchEvent

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
/**
 * 在触摸事件中, 处理上拉和下拉的逻辑
 */
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {

    if (contentView == null) {
        return super.dispatchTouchEvent(ev);
    }

    int action = ev.getAction();

    switch (action) {
        case MotionEvent.ACTION_DOWN:

            // 判断是否可以上拉和下拉
            canPullDown = isCanPullDown();
            canPullUp = isCanPullUp();

            // 记录按下时的Y值
            startY = ev.getY();
            break;

        case MotionEvent.ACTION_UP:

            if (!isMoved)
                break; // 如果没有移动布局, 则跳过执行

            // 开启动画
            TranslateAnimation anim = new TranslateAnimation(0, 0, contentView.getTop(), originalRect.top);
            anim.setDuration(ANIM_TIME);

            contentView.startAnimation(anim);

            // 设置回到正常的布局位置
            contentView.layout(originalRect.left, originalRect.top, originalRect.right, originalRect.bottom);

            // 将标志位设回false
            canPullDown = false;
            canPullUp = false;
            isMoved = false;

            break;
        case MotionEvent.ACTION_MOVE:

            // 在移动的过程中, 既没有滚动到可以上拉的程度, 也没有滚动到可以下拉的程度
            if (!canPullDown && !canPullUp) {
                startY = ev.getY();
                canPullDown = isCanPullDown();
                canPullUp = isCanPullUp();

                break;
            }

            // 计算手指移动的距离
            float nowY = ev.getY();
            int deltaY = (int) (nowY - startY);

            // 是否应该移动布局
            boolean shouldMove = (canPullDown && deltaY > 0) // 可以下拉, 并且手指向下移动
                    || (canPullUp && deltaY < 0) // 可以上拉, 并且手指向上移动
                    || (canPullUp && canPullDown); // 既可以上拉也可以下拉(这种情况出现在ScrollView包裹的控件比ScrollView还小)

            if (shouldMove) {

                // 计算偏移量
                int offset = (int) (deltaY * MOVE_FACTOR);

                // 随着手指的移动而移动布局
                contentView.layout(originalRect.left, originalRect.top + offset, originalRect.right, originalRect.bottom + offset);

                isMoved = true; // 记录移动了布局
            }

            break;
        default:
            break;
    }

    return super.dispatchTouchEvent(ev);
}
 
开发者ID:zwmlibs,项目名称:BookReader-master,代码行数:82,代码来源:ReboundScrollView.java

示例12: getShakeAnimation

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
public static TranslateAnimation getShakeAnimation(int count) {
        TranslateAnimation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
        translateAnimation.setInterpolator(new CycleInterpolator(count));
        translateAnimation.setDuration(1000);
        return translateAnimation;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:7,代码来源:AutoEditText.java

示例13: initHideAnimation

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
/**
 * 初始化向下隐藏的动画(最下面菜单的)
 */
private void initHideAnimation() {
    mHiddenAction = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, 0, -1.0f, Animation.RELATIVE_TO_SELF, 1.0f);
    mHiddenAction.setDuration(1000);
}
 
开发者ID:teisun,项目名称:SunmiUI,代码行数:8,代码来源:DownUpActivity.java

示例14: onCreateView

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
    View view = inflater.inflate(R.layout.fragment_collected_dcn, container, false);
    int amount = 0;

    Bundle arguments = getArguments();
    if (arguments != null && arguments.containsKey(KEY_DCN_AMOUNT)) {
        amount = arguments.getInt(KEY_DCN_AMOUNT);
    }

    ivCollectDentacoin = (ImageView) view.findViewById(R.id.iv_collect_dentacoin);
    tvCollectAmount = (DCTextView) view.findViewById(R.id.tv_collect_amount);
    tvCollectMessage = (DCTextView) view.findViewById(R.id.tv_collect_message);
    tvCollectAmount.setText(getString(R.string.txt_dcn, amount));

    Resources r = getResources();
    float translationPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, r.getDisplayMetrics());

    AlphaAnimation logoAnimation = new AlphaAnimation(0, 1);
    logoAnimation.setDuration(2000);
    ivCollectDentacoin.startAnimation(logoAnimation);

    TranslateAnimation thankYouTranslate = new TranslateAnimation(0, 0, translationPx, 0);
    thankYouTranslate.setDuration(1000);
    AlphaAnimation thankYouAlpha = new AlphaAnimation(0, 1);
    thankYouAlpha.setDuration(1000);

    AnimationSet animationSet = new AnimationSet(true);
    animationSet.addAnimation(thankYouTranslate);
    animationSet.addAnimation(thankYouAlpha);
    tvCollectAmount.startAnimation(animationSet);

    AlphaAnimation messageAnimation = new AlphaAnimation(0, 1);
    messageAnimation.setDuration(3500);
    tvCollectMessage.startAnimation(messageAnimation);

    runnable = new Runnable() {
        @Override
        public void run() {
            if (getActivity() != null) {
                getActivity().getFragmentManager().beginTransaction().remove(DCCollectSuccessFragment.this).commitAllowingStateLoss();
                if (listener != null)
                    listener.onFragmentRemoved();
            }
        }
    };

    handler.postDelayed(runnable, 5000);

    return view;
}
 
开发者ID:Dentacoin,项目名称:aftercare-app-android,代码行数:52,代码来源:DCCollectSuccessFragment.java

示例15: getTranslateAnimator

import android.view.animation.TranslateAnimation; //导入方法依赖的package包/类
private TranslateAnimation getTranslateAnimator(float targetX, float targetY) {
    TranslateAnimation translateAnimation = new TranslateAnimation(1, 0.0f, 0, targetX, 1, 0.0f, 0, targetY);
    translateAnimation.setDuration(ANIM_TIME);
    translateAnimation.setFillAfter(true);
    return translateAnimation;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:7,代码来源:ChannelFragmentAdapter.java


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