+ 3
Android: Persistent bottom sheet peek covering last RecyclerView item
I have implemented a persistent bottom sheet in my layout - one that cannot be completely hidden but always peeks from the bottom. But it covers the last RecyclerView item. How can I set the layout in such a way the peek doesn't hide the last item. I have put my xml here:- https://code.sololearn.com/W1ebVefpcJmy/#html
4 Answers
+ 2
Hi Sayan Kundu
<android.support.v7.widget.RecyclerView
...
android:paddingBottom="?dp"
android:clipToPadding="false" />
replace "?dp" with the height of your peek.
This way your recycler will add the specified space after last item and won't hide under your bottomsheet.
I also recommend you to make a separate layout file for your bottomsheet and then inflate it separately or use include tag to include the layout.
This will decrease your headache, trust me!
Also you can use that coordinator as your parent and delete the frameLayout.
Also! If you're using the nestedScrollView only for scrolling the recyclerView, You're wrong.
RecyclerView as it's name says will "recycle views". But you put it inside scrollView and set it's height to "wrap_content". So it won't ever recycle an item and only add new itemView to fill the height!
So you can remove nestedScrollView too!
+ 2
So you can change your layout to something like this:
<coordinator>
<recycler />
<linearCompat>
<include sheet layout/>
</linearCompat>
</coordinator>
+ 1
Sayan Kundu
You're welcome. I'm glad it helped you :)
I'm not sure about this one.
I never had this problem with bottomsheet.
But normally I face this kind of problems when I override or add onTouchListener that always returns false which causes passing the touch event to views behind it.
0
Abolfazl Naseri Wow. Thank you for your tips. It really helped me. âș
Another thing is: On touching on the Expanded bottomsheet calls the recylerView item click listener which is under its layout.
To solve this I have done:
bottomSheet.setOnclickListner((v)->{
//Do nothing
});
This avoids click event under its layout.
Is there any better solution for this?