Mehdi bahmanpour
Mehdi bahmanpour

Reputation: 614

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 ?

Upvotes: 6

Views: 7280

Answers (2)

Ramkumar.M
Ramkumar.M

Reputation: 691

use NestedScrollViewinstead of ScrollView

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

Upvotes: 13

Umair
Umair

Reputation: 6426

Try giving manual height to both recycleViews because they both are in a scrollview so it won't work if you give wrap_content or match_parent.

<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="5dp">

<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="500dp" />

    <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="500dp" />

</LinearLayout>

Upvotes: 0

Related Questions