创建一个比较长的过渡。 TransitionManager.beginDelayedTransition();太快 [英] Creating a slower transition. TransitionManager.beginDelayedTransition(); is too fast

查看:1494
本文介绍了创建一个比较长的过渡。 TransitionManager.beginDelayedTransition();太快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个过渡。并在单击按钮时执行下面的方法。该方法改变了尺寸,图像视图的位置,并且它消失了出来。我使用 TransitionManager.beginDelayedTransition();实在是太快了。来减缓过渡..但它仍然是走得太快。我能做些什么来过渡放缓。谢谢。

 私人无效moveIcon(){
    查看moveableIcon = findViewById(R.id.moveableImageView);    TransitionManager.beginDelayedTransition(myLayout);    //改变图标的​​位置    RelativeLayout.LayoutParams positionRule =新RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT,            RelativeLayout.LayoutParams.WRAP_CONTENT);
    positionRule.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);    positionRule.addRule(RelativeLayout.ALIGN_PARENT_LEFT,RelativeLayout.TRUE);    moveableIcon.setLayoutParams(positionRule);    //改变按钮的尺寸    ViewGroup.LayoutParams sizeRules = moveableIcon.getLayoutParams();
    sizeRules.width = 50;
    sizeRules.height = 50;
    moveableIcon.setLayoutParams(sizeRules);    fadeOutAndHideImage(图片);
}私人无效fadeOutAndHideImage(最终ImageView的IMG)
{
    动画淡出=新AlphaAnimation(1,0);
    fadeOut.setInterpolator(新AccelerateInterpolator());
    fadeOut.setDuration(1000);    fadeOut.setAnimationListener(新Animation.AnimationListener()
    {
        公共无效onAnimationEnd(动画动画)
        {
            img.setVisibility(View.GONE);
        }
        公共无效onAnimationRepeat(动画动画){}
        公共无效onAnimationStart(动画动画){}
    });    img.startAnimation(淡出);
}


解决方案

尝试用这个方法:[beginDelayedTransition(android.view.ViewGroup,android.transition.Transition)](<一个href=\"https://developer.android.com/reference/android/transition/TransitionManager.html#beginDelayedTransition(android.view.ViewGroup\" rel=\"nofollow\">https://developer.android.com/reference/android/transition/TransitionManager.html#beginDelayedTransition(android.view.ViewGroup, android.transition.Transition))

  AutoTransition autoTransition =新AutoTransition();
autoTransition.setDuration(3000);TransitionManager.beginDelayedTransition(myLayout,autoTransition);

I am creating a transition. And when a button is clicked the following method is executed. The method changed the size , position of the image view, and it fades it out. I am using TransitionManager.beginDelayedTransition(); is too fast. to slow down the transition.. but it is still going too fast. What can i do to slow down the transition. Thank You.

private void moveIcon() {
    View moveableIcon = findViewById(R.id.moveableImageView);

    TransitionManager.beginDelayedTransition(myLayout);

    // change the position of the icon

    RelativeLayout.LayoutParams positionRule = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT ,

            RelativeLayout.LayoutParams.WRAP_CONTENT);
    positionRule.addRule(RelativeLayout.ALIGN_PARENT_TOP , RelativeLayout.TRUE);

    positionRule.addRule(RelativeLayout.ALIGN_PARENT_LEFT , RelativeLayout.TRUE);

    moveableIcon.setLayoutParams(positionRule);

    // change the size of the button

    ViewGroup.LayoutParams sizeRules = moveableIcon.getLayoutParams();
    sizeRules.width = 50;
    sizeRules.height = 50;
    moveableIcon.setLayoutParams(sizeRules);

    fadeOutAndHideImage(image);
}

private void fadeOutAndHideImage(final ImageView img)
{
    Animation fadeOut = new AlphaAnimation(1, 0);
    fadeOut.setInterpolator(new AccelerateInterpolator());
    fadeOut.setDuration(1000);

    fadeOut.setAnimationListener(new Animation.AnimationListener()
    {
        public void onAnimationEnd(Animation animation)
        {
            img.setVisibility(View.GONE);
        }
        public void onAnimationRepeat(Animation animation) {}
        public void onAnimationStart(Animation animation) {}
    });

    img.startAnimation(fadeOut);
}

解决方案

Try use this method: [beginDelayedTransition(android.view.ViewGroup, android.transition.Transition)](https://developer.android.com/reference/android/transition/TransitionManager.html#beginDelayedTransition(android.view.ViewGroup, android.transition.Transition))

AutoTransition autoTransition = new AutoTransition();
autoTransition.setDuration(3000);

TransitionManager.beginDelayedTransition(myLayout, autoTransition);

这篇关于创建一个比较长的过渡。 TransitionManager.beginDelayedTransition();太快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆