Android ConstraintLayout文本视图

Android ConstraintLayout文本视图,android,android-layout,textview,android-view,android-constraintlayout,Android,Android Layout,Textview,Android View,Android Constraintlayout,两个文本视图在ConstraintLayout内相互重叠,如图所示 如何解决这个问题 遵循示例代码: <android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp"> <TextView android

两个文本视图在ConstraintLayout内相互重叠,如图所示

如何解决这个问题

遵循示例代码:

<android.support.constraint.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="16dp">

    <TextView
        android:id="@+id/textView1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="24dp"
        android:layout_marginRight="24dp"
        android:layout_marginTop="24dp"
        android:text="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="24dp"
        android:layout_marginLeft="24dp"
        android:layout_marginRight="24dp"
        android:layout_marginTop="8dp"
        android:text="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView1" />

</android.support.constraint.ConstraintLayout>


应用程序:layout\u constraintBottom\u toTopOf=“@+id/textView2”
添加到
textView1
以将两者分开。我不知道你为什么会看到你正在看到的东西,但这会起作用。

如果你将
android:singleLine=“true”
同时添加到
TextView
s会发生什么?对不起,我是第一个问题,标题错了,对的是“在约束布局中,两个多行TextView内容重叠”。在您的“预览”中,您在右侧显示文本已被截断并固定为一行-这不是您想要的?@Jack Parkinson,但我需要显示预览中的多行内容。看起来边距将您的
TextView
s向上推并重叠。试着把它们变小。这可以解决我的问题。在我的情况下,
textview2
不仅要设置
app:layout\u constraintotop\u toBottomOf=“@+id/textView1”
textView1
还需要设置
app:layout\u constraintBottom\u topof=“@+id/textview2”
,否则
ConstraintLayout
高度计算可能会出错。