RecycleView中的DrawLayout

时间:2017-05-15 15:20:45

标签: android

我想在RecycleView中使用DrawLayout作为滑动菜单。 但这是一个问题。 我在onBindViewHolder方法中关闭抽屉如果重复使用View,抽屉确实关闭,但抽屉内的视图仍然存在。 也许描述不清楚,请查看下面的截图:

这是Recycleview,我在抽屉里有一个ic_launcher imageView: screenshot0

ITEM LAYOUT

/

然后滚动recycleView,会发生这种情况: screenshot1

<android.support.v4.widget.DrawerLayout
    android:id="@+id/dl"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <android.support.constraint.ConstraintLayout
        android:id="@+id/cl_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ImageView
            android:id="@+id/iv_content"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:src="@color/colorPrimaryDark"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </android.support.constraint.ConstraintLayout>

    <android.support.constraint.ConstraintLayout
        android:id="@+id/cl_menu"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="end">

        <ImageView
            android:id="@+id/iv_menu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@mipmap/ic_launcher"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </android.support.constraint.ConstraintLayout>
</android.support.v4.widget.DrawerLayout>

抽屉(cl_menu)被解雇,但抽屉内的视图(ic_launcher)仍然存在。我不知道错误在哪里,有什么想法吗?谢谢!

0 个答案:

没有答案