idu*_*olz 15 android android-constraintlayout
我想使用没有嵌套的ConstraintLayout实现下面的布局。
布局需要一个障碍,因为不能保证哪个textview会更高。这也需要一条链,因为一切都需要居中。问题是我找不到使壁垒与壁垒一起工作的方法。
到目前为止,这是我可以正确布局但不会居中的内容:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:id="@+id/topLeftText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
tools:text="Test test test test test test test test test test"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/topRightText"/>
<TextView
android:id="@+id/topRightText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
tools:text="Test test test test test test test test test test test test test test test test test test test test"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@+id/topLeftText"
app:layout_constraintEnd_toEndOf="parent"/>
<android.support.constraint.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="topLeftText,topRightText"
app:barrierDirection="bottom"/>
<TextView
android:id="@+id/bottomText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="16dp"
tools:text="Test test test test test test test test test test test test test test test test test test test test"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/barrier"/>
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)
如果有人知道如何实现这一目标,将不胜感激!
我知道它很旧,但我认为要在不嵌套的情况下做到这一点,您必须将顶部组件更改为类似的东西。
android:layout_height="wrap_content" android:layout_gravity="center"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
272 次 |
| 最近记录: |