我已经读过this guide,但是我不知道该怎么做。
我拥有的是一条包含所有元素的规则链,链模式为“散布在内部”:
我想要的是右边带有向上和向下箭头的按钮,而“ 4”文本在剩余空间中均匀分布:
我的xml:
<TextView
android:id="@+id/tv_sel_rep_1"
android:layout_width="11dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@{String.valueOf(exercise.set1Reps)}"
android:textSize="24sp"
android:visibility="@{exercise.isActive && !exercise.isTimedExercise? View.VISIBLE : View.GONE}"
app:layout_constraintEnd_toStartOf="@+id/tv_sel_rep_2"
app:layout_constraintHorizontal_chainStyle="spread"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/sp_sel_exer"
tools:text="4" />
<TextView
android:id="@+id/tv_sel_rep_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@{String.valueOf(exercise.set2Reps)}"
android:textSize="24sp"
android:visibility="@{exercise.isActive && !exercise.isTimedExercise? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="@+id/tv_sel_rep_1"
app:layout_constraintEnd_toStartOf="@+id/tv_sel_rep_3"
app:layout_constraintStart_toEndOf="@+id/tv_sel_rep_1"
app:layout_constraintTop_toTopOf="@+id/tv_sel_rep_1"
tools:text="4" />
<TextView
android:id="@+id/tv_sel_rep_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@{String.valueOf(exercise.set3Reps)}"
android:textSize="24sp"
android:visibility="@{exercise.isActive && !exercise.isTimedExercise? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="@+id/tv_sel_rep_2"
app:layout_constraintEnd_toStartOf="@+id/b_sel_increase_reps_small"
app:layout_constraintStart_toEndOf="@+id/tv_sel_rep_2"
app:layout_constraintTop_toTopOf="@+id/tv_sel_rep_2"
tools:text="4" />
<TextView
android:id="@+id/tv_sel_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
android:minHeight="0dp"
android:text="@{String.valueOf(exercise.setTime)}"
android:visibility="@{exercise.isActive && exercise.isTimedExercise? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="@+id/b_sel_increase_reps_small"
app:layout_constraintEnd_toStartOf="@+id/b_sel_increase_reps_small"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/b_sel_increase_reps_small"
tools:text="30"
tools:visibility="gone" />
<Button
android:id="@+id/b_sel_increase_reps_small"
android:layout_width="44dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:onClick="@{() -> viewModel.incrementSet(exercise, true)}"
android:padding="16dp"
android:text="↑"
android:textSize="24sp"
android:visibility="@{exercise.isActive? View.VISIBLE: View.GONE}"
app:layout_constraintBottom_toBottomOf="@+id/tv_sel_rep_3"
app:layout_constraintEnd_toStartOf="@+id/b_sel_reduce_reps_small"
app:layout_constraintStart_toEndOf="@+id/tv_sel_rep_3"
app:layout_constraintTop_toTopOf="@+id/tv_sel_rep_3" />
<Button
android:id="@+id/b_sel_reduce_reps_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_marginEnd="8dp"
android:minWidth="0dp"
android:minHeight="0dp"
android:onClick="@{() -> viewModel.decrementSet(exercise, true)}"
android:padding="16dp"
android:text="↓"
android:textSize="24sp"
android:visibility="@{cbActiveExer.checked? View.VISIBLE: View.GONE}"
app:layout_constraintBottom_toBottomOf="@+id/b_sel_increase_reps_small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/b_sel_increase_reps_small"
app:layout_constraintTop_toTopOf="@+id/b_sel_increase_reps_small" />