RecyclerView ScrollListener - Animate view visibility

0

I want a view containing a few buttons to disappear and appear when I slide recycleview as in the coordinator layout:

butthisiscurrentlyso,andithasnoanimation,justdisappearandappears:

Currentcode:

rv_noticas.addOnScrollListener(newRecyclerView.OnScrollListener(){@OverridepublicvoidonScrolled(RecyclerViewrecyclerView,intdx,intdy){super.onScrolled(recyclerView,dx,dy);y=dy;if(dy>0){Log.i(TAG,"onScrolled: " + "DOWN");
                //layoutbotoes.setVisibility(View.GONE);
                layoutbotoes.setVisibility(View.GONE);

            } else {
                Log.i(TAG, "onScrolled: " + "UP");
                layoutbotoes.setVisibility(View.VISIBLE);


                // Scrolling down
                //layoutbotoes.setVisibility(View.VISIBLE);

            }
        }

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if(RecyclerView.SCROLL_STATE_IDLE ==newState){
                // fragProductLl.setVisibility(View.VISIBLE);
                if(y<=0){
                    layoutbotoes.setVisibility(View.VISIBLE);


                }
                else{
                    y=0;
                    layoutbotoes.setVisibility(View.GONE);
                }
            }
        }


    });
    
asked by anonymous 10.01.2018 / 15:49

1 answer

2

Try to put this in the xml of the layout, at the top that part

    xmlns:app="http://schemas.android.com/apk/res-auto"

Then in the layout where the buttons meet

app:layout_scrollFlags="scroll|enterAlways"

In case I use this to be the same as the first image, where the Toolbar hides according to the scroll

    
10.01.2018 / 16:33