ImageView 在为 RecyclerView 重用时改变了 ConstraintLayout 中的位置

ImageView changes position in ConstraintLayout when reusing for RecyclerView

我对新的约束布局有一些疑问。 我正在使用 RecyclerView,该项目的布局基于其中包含 2 个 TextView 和 1 个 ImageView 的约束布局。 在设计视图中,在 Android Studio 中,一切看起来都很好,但在实际设备(带有 Lineage OS 的 S5)上,ImageView 在某些活动中改变了它的位置。 如果我向下滚动,这些项目就是它们应该的样子,当向上滚动时,一切都会恢复正常。 我提到我正在使用 Recycler 视图为 3 个片段重用相同的布局文件。 这是 1 个列表项的布局。

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cont_item_root"
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="@drawable/bottom_border"
android:paddingRight="16dp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:paddingLeft="16dp">

<TextView
    android:id="@+id/lbl_item_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginTop="0dp"
    android:gravity="center"
    android:text="wqewqwewqeqw"
    android:textColor="@android:color/black"
    android:textSize="16sp"
    app:layout_constraintBottom_toTopOf="@+id/lbl_item_desc"
    app:layout_constraintHorizontal_bias="0.008"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="1.0" />
<TextView
    android:id="@+id/lbl_item_desc"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:textSize="14sp"
    android:text="weqweweqweweqeweqwe"
    android:layout_marginRight="0dp"
    android:layout_marginEnd="72dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="@+id/lbl_item_title"
    android:layout_marginBottom="7dp"
    app:layout_constraintRight_toRightOf="@+id/lbl_item_title"
    app:layout_constraintHorizontal_bias="0.0"/>
<ImageView
    android:id="@+id/lbl_item_save"
    android:contentDescription="@string/bookmarked"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_star_border_black_24dp"
    android:layout_marginEnd="8dp"
    app:layout_constraintTop_toTopOf="parent"
    android:layout_marginTop="8dp"
    app:layout_constraintBottom_toBottomOf="parent"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginRight="24dp"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintLeft_toRightOf="@+id/lbl_item_desc"
    android:layout_marginLeft="8dp"
    app:layout_constraintHorizontal_bias="1.0" />

在 phone 上,在第一个片段中,无论我以何种顺序打开它,一切都很好。但是如果我打开第二个或第三个片段,事情就会变得一团糟。

有人知道什么会影响 ImageView(星星)移动吗?

谢谢!

找到答案了。 包含 RecyclerView 的父布局也使用了约束布局,它们之间似乎存在一些冲突。 将根布局更改为 RelativeLayout 或 LinearLayout 后,一切恢复正常。