5

RecyclerViews在一个LinearLayout里面有 2 个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 中!

所以有什么问题 ?

4

2 回答 2

12

使用NestedScrollView而不是ScrollView

并添加recyclerView.setNestedScrollingEnabled(false);到您的RecyclerView

于 2018-04-19T16:15:13.277 回答
0

height尝试为两个recycleViews提供手册,因为它们都在 a 中,因此如果您提供orscrollview它将不起作用。wrap_contentmatch_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>

于 2018-04-19T14:10:24.737 回答