【发布时间】:2020-07-17 19:16:01
【问题描述】:
我在约束布局内有一个TextView,用于在RecyclerView 内布局我的项目。一些奇怪的行为正在发生。当应用程序第一次启动时,宽度是正确的,但是当我向上和向下滚动时,TextView 的宽度发生了变化,现在正在填充额外的空间。
代码
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="80dp"
android:layout_marginEnd="64dp"
android:background="#C3C3C3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_max="wrap"
tools:text="hello there" />
原文:
滚动后:
这种行为是否有原因,如何将其修复为预期的?
【问题讨论】:
-
您尝试过布局检查器吗?也许你会在滚动后发现它的一些不同之处。 developer.android.com/studio/debug/layout-inspector
-
@einUsername 我做到了,但也无法弄清楚
标签: android android-layout android-recyclerview textview android-constraintlayout