在使用 alignParentBottom 的相对布局中,如何在我的代码中的约束布局中使用相同的布局?
In Relative Layout as alignParentBottom is used,How the same can be used in Constraint layout in my code?
在给定的图像中,我使用 android:layout_alignParentBottom="true" 作为第二个文本视图,以获取底部的剩余可用区域。
如何在约束布局中完成这(第二个文本视图获取可用 space 底部)。
相对于约束布局的转换不会在此处产生相同的结果。
相对布局
<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_constraintEnd_toEndOf
和 app:layout_constraintStart_toStartOf
是为了使视图像 match_parent
.
app:layout_constraintTop_toBottomOf="@+id/tv1"
因此视图将低于 tv1。
而app:layout_constraintBottom_toBottomOf="parent"
是视图会一直延伸到父级(屏幕)的底部
在给定的图像中,我使用 android:layout_alignParentBottom="true" 作为第二个文本视图,以获取底部的剩余可用区域。
如何在约束布局中完成这(第二个文本视图获取可用 space 底部)。
相对于约束布局的转换不会在此处产生相同的结果。
相对布局
<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_constraintEnd_toEndOf
和 app:layout_constraintStart_toStartOf
是为了使视图像 match_parent
.
app:layout_constraintTop_toBottomOf="@+id/tv1"
因此视图将低于 tv1。
而app:layout_constraintBottom_toBottomOf="parent"
是视图会一直延伸到父级(屏幕)的底部