Android 是否防止文本视图在ConstraintLayout中重叠?
我遇到了一个问题,Android 是否防止文本视图在ConstraintLayout中重叠?,android,android-constraintlayout,Android,Android Constraintlayout,我遇到了一个问题,“Den Dolder”文本视图总是与日期文本视图重叠。我试过使用app:layout\u constraintRight\u toLeftOf=“@id/date\u txtView”,但毫无效果 没关系: 那不好: 短解决方案: 尝试将app:layout\u constraint\u weight=“1”和android:layout\u width=“0dp”添加到两个文本视图中-它们在布局中的宽度相同 针对更复杂布局的另一种解决方案: 您需要告诉两个文本视图的宽度均
“Den Dolder”
文本视图总是与日期文本视图重叠。我试过使用app:layout\u constraintRight\u toLeftOf=“@id/date\u txtView”
,但毫无效果
没关系:
那不好:
短解决方案: 尝试将
app:layout\u constraint\u weight=“1”
和android:layout\u width=“0dp”
添加到两个文本视图中-它们在布局中的宽度相同
针对更复杂布局的另一种解决方案:
您需要告诉两个文本视图的宽度均为0dp
,这样,如果文本太长,它们将删除一行
例如,在两个文本视图之间设置如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
app:layout_constraintEnd_toStartOf="@+id/textView4"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView3"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>