4

I have a BottomsheetDialogFragment which has a normal Fragment which has a recyclerview. The problem is I am not able to scroll the recyclerview.

I thought of using the NestedScrollView but I have a search functionality inside the fragment. When the Keypad pops up, its working fine but as soon as the keypad hide the transition of the bottomsheet coming down is not okay. So, i am not able to use that.

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinatorlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/whitebackground"


    android:focusable="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/whitebackground"
        >



    </RelativeLayout>

</android.support.design.widget.CoordinatorLayout>

And at runtime i am inflating the layout which contains the recyclerview.

RKRK
  • 1,284
  • 5
  • 14
  • 18
Aman Verma
  • 3,155
  • 7
  • 30
  • 60
  • Have you tried making "fillviewport" attribute of scrollview to be true and cause the recyclerview to enable nestedscrolling ? using this line right after you set recyclerview adapter ViewCompat.setNestedScrollingEnabled(recyclerView, false); – Hossam Eldeen Onsy Jun 01 '19 at 22:02
  • Have you tried validating your relative layout after adding recyclerview? – Moinkhan Jun 03 '19 at 06:59
  • Can you define what is `not okay`? A video would be helpful. – Eren Utku Jun 04 '19 at 08:51
  • I have manged to do the scrolling part but now the new error comes. I have set the height of the recyclerview around 500dp. There is a space at the bottom and the recyclerview is shifter up to the top of the screen. – Aman Verma Jun 04 '19 at 13:44
  • @Sniper hey, please share your solution or please provide feedback to the answers. Otherwise whoever visits this question will go empty hand. Community trying to help you, please help back. – Eren Utku Jun 07 '19 at 09:04

3 Answers3

2

You can use isNestedScrollingEnabled property inside a fragment or activity.

recyclerOuter.isNestedScrollingEnabled = false
0

Since your problem starting with the keyboard you can try to add following line to activity definition in your AndroidManifest.xml. This line will make sure when the keyboard pops up your view will not resize. <activity... android:windowSoftInputMode="adjustResize" .../>

And you should add to your coordinator layout android:fitsSystemWindows="true"

Eren Utku
  • 1,731
  • 1
  • 18
  • 27
0

You want to intercept touch event for recyclerview rather than BottomSheet layout. Default when you touch to scroll the event triggers in bottomsheet layout not on recyclerview. Use below code to intercept the touch event for recyclerview forcefully

<androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerViewNotes"
        android:layout_width="match_parent"
        android:focusableInTouchMode="true"
        android:layout_height="match_parent"/>


recyclerViewNotes?.setOnTouchListener { v, event ->
            v.parent.requestDisallowInterceptTouchEvent(true)
            v.onTouchEvent(event)
            true
        }
Naveen Kumar M
  • 7,497
  • 7
  • 60
  • 74