在更改视图的可见性时应用动画

Vip*_*l J 3 animation android

我在我的应用程序中有一个Horizo​​ntalScrollView,我正常使用它的可见性(VISIBLE和GONE).所以我想要的是,我可以应用某种动画或某种东西,而不是突然使它变得可见和不可见,以便它会以滑动的方式开始变得可见和不可见吗?

任何帮助或建议将受到高度赞赏.提前致谢.

omi*_*301 7

你可以试试这个:

Animation animation = new TranslateAnimation(0,0,0,1000);
animation.setDuration(1000);
yourButtonorImage.startAnimation(animation);
Run Code Online (Sandbox Code Playgroud)

要使其可见或不可见,您可以使用setAnimationListener.在onAnimationEnd中,使其可见或不可见.不知道这是不是你的意思..希望它有帮助..


Jav*_*tor 5

尝试这个..

youView.setVisibility(View.VISIBLE);
ObjectAnimator anim = ObjectAnimator.ofFloat(youView, "alpha", 0f, 1f);
anim.setDuration(1000);
anim.start();
Run Code Online (Sandbox Code Playgroud)

应用了 API 级别限制。