Android 在使用alignParentBottom的相对布局中,如何在我的代码中的约束布局中使用相同的布局?

Android 在使用alignParentBottom的相对布局中,如何在我的代码中的约束布局中使用相同的布局?,android,android-layout,android-constraintlayout,Android,Android Layout,Android Constraintlayout,在给定的图像中,我使用android:layout\u alignParentBottom=“true”作为第二个文本视图,以获取底部剩余的可用区域 如何在约束布局中执行此操作(第二个文本视图以获取底部可用空间) 相对于约束布局进行转换在此处不会产生相同的结果 相对布局 <TextView android:id="@+id/tv1" android:layout_width="match_parent" android:layout_

在给定的图像中,我使用android:layout\u alignParentBottom=“true”作为第二个文本视图,以获取底部剩余的可用区域

如何在约束布局中执行此操作(第二个文本视图以获取底部可用空间)

相对于约束布局进行转换在此处不会产生相同的结果

相对布局

    <TextView
        android:id="@+id/tv1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello World!"
/>
    <TextView
        android:layout_below="@id/tv1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#499989"
        android:text="Hello World!"
        android:layout_alignParentBottom="true"
        />


您可以这样使用它:

<?xml version="1.0" encoding="utf-8"?><?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/tv1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_below="@id/tv1"
        android:background="#499989"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv1"
        tools:layout_editor_absoluteX="0dp" />

</android.support.constraint.ConstraintLayout>

app:layout\u constraints\u to endof
app:layou constraints start\u to start of
是为了使视图像
一样匹配父视图

app:layout_constraintTop_toBottomOf=“@+id/tv1”
因此视图将位于tv1下方


app:layout\u constraintBottom\u toBottomOf=“parent”
则表示视图将一直延伸到父视图(屏幕)的底部

谢谢您的帮助…但这只是将第二个文本视图移到底部。但这不起作用。它只是将第二个文本视图移到底部。我希望我的第二个文本视图垂直获取完整的可用空间。有一个约束布局…然后是一个文本视图。第一个文本视图正下方有第二个文本视图(背景色为绿色,文本颜色为黑色)…现在,我希望我的第二个文本视图填充从第一个文本视图的下边缘到屏幕底部的可用空间(显示背景色为绿色)。支持提供问题的图像。