ConstraintLayout玩法
# ConstraintLayout玩法
# 1 同一行,左右排列,互怼,某一边必须一行,某一边自动换行
实现方式:
1 首尾互相约束成链(chain)
2 链头部item声明chain的空间排布方式: app:layout_constraintHorizontal_chainStyle="spread_inside"
3 自动换行的item : android:layout_width="0dp" + app:layout_constraintHorizontal_weight="1"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_marginTop="16dp"
android:layout_height="wrap_content">
<TextView
android:text="@string/xxxxxxxxxxxxxxx"
android:textSize="14dp"
android:textColor="#666666"
android:fontFamily="@font/roboto_medium"
android:id="@+id/tv_pay_await_status"
app:layout_constraintTop_toBottomOf="@id/tv_pay_success_time"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginLeft="28dp"
app:layout_constraintRight_toLeftOf="@id/tv_pay_await_amount"
android:layout_marginTop="16dp"
android:layout_width="0dp"
app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintHorizontal_weight="1"
android:layout_marginBottom="2dp"
android:layout_height="wrap_content"/>
<TextView
tools:text="Rp10000000000000000000000000000"
android:layout_marginLeft="12dp"
android:textSize="14dp"
android:textColor="#F0463C"
android:fontFamily="@font/roboto_bold"
android:id="@+id/tv_pay_await_amount"
app:layout_constraintTop_toTopOf="@id/tv_pay_await_status"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@id/tv_pay_await_status"
android:layout_width="wrap_content"
android:layout_marginBottom="2dp"
android:layout_height="wrap_content"/>
</androidx.constraintlayout.widget.ConstraintLayout>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 参考
编辑 (opens new window)
上次更新: 2022/08/25, 20:20:31