RecyclerView не показывает все элементы в ScrollView
У меня есть 2 RecyclerViews
в LinearLayout
внутри 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>
оба переработчика имеют nestedScrollEnabled
вспышка
проблема здесь: когда рендеринг макета, первый recyclerView заполнится, а второй recyclerView внизу экрана не будет отображать все элементы из-за первой высоты!! Но он должен прокручиваться, потому что они оба в scrollView!
так в чем проблема?
2 ответа
Решение
Использование NestedScrollView
вместо ScrollView
и добавить recyclerView.setNestedScrollingEnabled(false);
на ваш RecyclerView
Попробуйте дать руководство height
к обоим recycleViews, потому что они оба находятся в scrollview
так что это не сработает, если вы дадите wrap_content
или же 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>