我有一个约束布局,布局看起来像这样-

正如您所看到的,项目Pasta和10:10在另一个的下方对齐。我同样的布局看起来像这样-
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView 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:id="@+id/food_item"
style="@style/cardViewStyle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/margin_16dp">
<com.google.android.material.textview.MaterialTextView
android:id="@+id/food_name_label"
style="@style/cardViewTextTitle"
android:text="@string/food_name"
app:layout_constraintBaseline_toBaselineOf="@+id/food_name_value"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/food_name_value"
style="@style/cardViewTextSubTitle"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.39"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Pasta" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/food_intake_label"
style="@style/cardViewTextTitle"
android:text="@string/food_intake_time"
app:layout_constraintBaseline_toBaselineOf="@+id/food_intake_value"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/food_intake_value"
style="@style/cardViewTextSubTitle"
app:layout_constraintStart_toEndOf="@id/food_intake_label"
app:layout_constraintTop_toBottomOf="@id/food_name_value"
tools:text="10:10" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>我让id food_name_value水平地对齐了父元素的开始和结束。
我的问题是,由于标签Intake Time比标签Name长得多,我是否正确地将food_name_value和food_intake_value在另一个下方对齐,或者在我的情况下,最好的对齐方式是什么?
https://stackoverflow.com/questions/64957541
复制相似问题