Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android objectanimator从上到下展开/折叠动画?_Android_Android Animation_Objectanimator - Fatal编程技术网

android objectanimator从上到下展开/折叠动画?

android objectanimator从上到下展开/折叠动画?,android,android-animation,objectanimator,Android,Android Animation,Objectanimator,我一直在尝试不同的方法来使用object animator获得展开/折叠动画,但到目前为止没有一种方法有效 我曾经使用过,而且它可以工作,但是当我阅读文档时,它说更倾向于使用animator来永久地为对象设置动画,而不是动画 我的代码的问题是它总是从视图的顶部开始,但我需要从底部展开/折叠视图 这是我的密码: public boolean collapse( View view, int start, int end ) { AnimatorSet set = new AnimatorS

我一直在尝试不同的方法来使用object animator获得展开/折叠动画,但到目前为止没有一种方法有效

我曾经使用过,而且它可以工作,但是当我阅读文档时,它说更倾向于使用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;
}

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

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

谢谢,它起作用了。虽然,属性名应该用小写字母“bottom”来写。谢谢,这很有效。不过,属性名称应使用小写字母“bottom”书写。