简体   繁体   English

如何使RecyclerView带有动画出现?

[英]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.

相关问题 将项目插入到 recyclerview 中时如何制作动画? - How can I make an animation when I insert an item into recyclerview? 每次发送或接收消息时,如何使最后联系的用户出现在 recyclerview 的列表顶部? - How can I make last contacted user appear on top of list in recyclerview each time a message is sent or received? 我如何使Recyclerview出现在mapview的顶部 - How do i make Recyclerview appear on top of mapview 我怎样才能让我的recyclerview半透明 - How can i make my recyclerview translucent 如何制作覆盖 recyclerView 的背景? - How can I make a background overlaying the recyclerView? 如何在中心制作 recyclerView 的项目? - How can i make items of recyclerView in center? 如何让我的 retrofit 调用出现在 recyclerview 中? - How to make my retrofit call appear in recyclerview? 如何使水平recyclerview出现在屏幕底部? - How to make a horizontal recyclerview appear bottom of the screen? 我如何使按钮出现 - how can I make the button appear 如何将我在EditText中输入的数据插入到数据库中并显示在recyclerview上而不像ajax那样刷新它? - how do I make the data I input in the EditText inserted into the database and appear on the recyclerview without refreshing it like ajax?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM