【问题标题】:android objectanimator expand/collapse from top to bottom animation?android objectanimator 从上到下展开/折叠动画?
【发布时间】:2014-05-03 22:17:08
【问题描述】:

我一直在尝试不同的方法来使用对象动画师获得展开/折叠动画,但到目前为止,它们都没有奏效。

我使用过 this solution 并且它可以工作,但是当我阅读文档时,它说使用 animator 来永久动画对象而不是动画更可取。

我的代码的问题是它总是从视图顶部开始,但我需要从底部展开/折叠视图。

这是我的代码:

public boolean collapse( View view, int start, int end )
{
    AnimatorSet set = new AnimatorSet();
    ObjectAnimator a = ObjectAnimator.ofFloat( view, "translationY", start, end );
    set.play( a );
    set.setDuration( 3000L );
    set.setInterpolator( new LinearInterpolator() );
    set.addListener( new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd( Animator animation )
        {
        }
    } );
    set.start();
    return true;
}

【问题讨论】:

    标签: android android-animation objectanimator


    【解决方案1】:

    尝试使用ObjectAnimator.ofInt 并使用bottom 的属性名称。这将从视图的底部开始动画。 TranslationY 对应于视图的顶部。

    【讨论】:

    • 谢谢,它成功了。不过,属性名称应该写成小写的“bottom”。
    猜你喜欢
    • 2017-03-09
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    • 1970-01-01
    • 2017-02-21
    • 2011-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多