Search code examples
androidandroid-layoutandroid-recyclerviewnestedrecyclerview

RecyclerView does not showing all items when its in a ScrollView


I Have 2 RecyclerViews in a LinearLayout inside a ScrollView :

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="@dimen/few_value">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <com.foodjoo.fjco.customViews.BYekanFontText
            android:id="@+id/market_category"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:padding="@dimen/normal_plus_value"
            android:text=" لبنیات > مارکت پیکی علی  "
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead"
            android:textColor="@color/light_black2" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/market_cat_recycler"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <com.foodjoo.fjco.customViews.BYekanFontText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="right"
            android:padding="@dimen/normal_plus_value"
            android:text="ساعات کار"
            android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead"
            android:textColor="@color/light_black2" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/market_hours_recycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </LinearLayout>
</ScrollView>

both recyclers have nestedScrollEnabled flase .

the problem is here : when the layout rendered, first recyclerView will fill and the second recyclerView in bottom of screen will not showing all items because of first one height !! But it should scroll , because both of them are in scrollView !!

so Whats the Problem ?


Solution

  • use NestedScrollViewinstead of ScrollView

    and add recyclerView.setNestedScrollingEnabled(false); to your RecyclerView