从RecyclerView到RecyclerView:单元格高度无法正常工作

时间:2019-05-12 13:17:48

标签: android android-recyclerview

我在单元格视图定义中有一个RecyclerView:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="2dp"
    android:paddingBottom="2dp"
    android:background="@android:color/white"
    android:foreground="?android:attr/selectableItemBackground">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="@dimen/keyline_1"
        android:orientation="horizontal">

        ...

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="@dimen/keyline_0"
            android:paddingRight="@dimen/keyline_1">

            ...

            <EditText
                android:id="@+id/description"
                style="@style/ItemListSubTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/header"
                android:layout_marginTop="3dp"
                android:focusable="false"
                android:lineSpacingExtra="2dp"
 android:inputType="textMultiLine|textCapSentences|textNoSuggestions"
                android:background="@null"
                android:visibility="gone"/>

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/list"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/header"
                android:layout_marginTop="3dp"
                android:clickable="false"
                android:focusable="false"
                android:scrollbars="none"
                android:clipToPadding="false"
                android:scrollingCache="true"
                android:overScrollMode="never"
                android:animationCache="false"
                android:smoothScrollbar="true"
                android:fastScrollEnabled="true"
                android:visibility="gone"/>

        </RelativeLayout>

    </LinearLayout>

</FrameLayout>

我正确设置了这些参数:

mListView.setHasFixedSize(true);
ViewCompat.setNestedScrollingEnabled(mListView, false);

对于第一个全局列表创建,它可以完美运行。 但是,如果我更新此列表,则会出现一些麻烦,例如:

enter image description here

您对这个问题有一些想法吗?

0 个答案:

没有答案
相关问题