在给定的图像中,我使用android:layout_alignParentBottom =“true”作为第二个文本视图,以获取底部的剩余可用区域。
如何(在底部获取可用空间的第二个文本视图)可以在Constraint布局中完成。
转换相对于约束布局不会产生相同的结果。
相对布局
<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"
/>
答案 0 :(得分:1)
你可以这样使用它:
<?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_constraintEnd_toEndOf
和app:layout_constraintStart_toStartOf
用于制作match_parent
之类的观点。
app:layout_constraintTop_toBottomOf="@+id/tv1"
所以视图将在tv1下面。
app:layout_constraintBottom_toBottomOf="parent"
是视图将延伸到父(屏幕)的底部