3

In my app I am using Activity & Fragment.Collapsing ToolBar is in Activity and RecyclerView is in Fragment.

I have attached two images. * Before Scrolling * After Scrolling the items are gone up.So created an empty space at the Bottom.

Here I need to stop the collapsing if the recyclerview has visible items at there. If items are more, scroll has to be enabled.How to do this? Please help. Even I referred the below link. But there is no combination of Activity & Fragment Collapsing ToolBar scrolling.

How to disable scrolling of NestedScrollView&CollapsingToolbarLayout, for example when there is no more content below?

enter image description here

Community
  • 1
  • 1
Parama Sudha
  • 2,583
  • 3
  • 29
  • 48

1 Answers1

0

Create AppBar layout public in activity and in fragment according to recycle view count set expand like this

               int itemCount=adapter.size();
               if(itemCount>4){
                    ((YourActivity)getActivity()).appBarLayout.setExpanded(true,true);
                }else{
                    ((YourActivity)getActivity()).appBarLayout.setExpanded(false,true);
                }

adapter.size() refers to your recycleview adapter count

Burhanuddin Rashid
  • 5,260
  • 6
  • 34
  • 51