Android: Persistent bottom sheet peek covering last RecyclerView item | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

15th May 2019, 5:36 AM
Sayan Kundu
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!
19th May 2019, 2:14 PM
Abolfazl
Abolfazl - avatar
+ 2
So you can change your layout to something like this: <coordinator> <recycler /> <linearCompat> <include sheet layout/> </linearCompat> </coordinator>
19th May 2019, 2:17 PM
Abolfazl
Abolfazl - avatar
+ 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.
20th May 2019, 11:34 AM
Abolfazl
Abolfazl - avatar
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?
19th May 2019, 5:18 PM
Sayan Kundu