[英]How can I make appear RecyclerView with an animation?
In my app if I press a button (the green one on the screenshot) I set my RecyclerView from height 0 to 600 and even if I re-press the same button it disappear by setting it height to 0. 在我的应用程序中,如果我按下一个按钮(屏幕截图上的绿色按钮),则将RecyclerView的高度设置为0到600,即使我再次按下同一按钮,也将其高度设置为0,它就会消失。
But actually it's ugly to see because it's appear instantly so I would like to add an animation to it like it's growing up slowly or bouncing, I don't know, something that would make it nicer. 但是实际上看起来很丑陋,因为它会立即出现,所以我想向它添加动画,就像它正在慢慢长大或弹跳一样,我不知道,这会使它变得更好。 Is there a way to make something like this? 有没有办法做这样的事情?
Here is my code where I make appear or disappear the RecyclerView: 这是我使RecyclerView出现或消失的代码:
menu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ViewGroup.LayoutParams params = mRecyclerViewBOT.getLayoutParams();
if(params.height == 0) {
params.height = 600;
mRecyclerViewBOT.setLayoutParams(params);
}else {
params.height = 0;
mRecyclerViewBOT.setLayoutParams(params);
}
}
});
You probably want: 您可能想要:
LayoutTransition layoutTransition = new LayoutTransition();
layoutTransition.enableTransitionType(LayoutTransition.CHANGING);
parentView.setLayoutTransition(layoutTransition);
where parentView is the view containing your recyclerView 其中parentView是包含您的recyclerView的视图
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.