android objectanimator从上到下展开/折叠动画?
我一直在尝试不同的方法来使用object animator获得展开/折叠动画,但到目前为止没有一种方法有效 我曾经使用过,而且它可以工作,但是当我阅读文档时,它说更倾向于使用animator来永久地为对象设置动画,而不是动画 我的代码的问题是它总是从视图的顶部开始,但我需要从底部展开/折叠视图 这是我的密码: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
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”书写。