我正在尝试制作一个在同一行上有两个UILabel的单元格.
像这样:
像这样:
User Name: blablabla
用户名是第一个UILabel,blablabla是第二个UILabel.
我希望第一个UILabel包装内容,第二个将其内容扩展到超级视图的尾随.
我试图围绕StackOverflow寻找我的问题的答案,但我找不到一个.有人知道我怎么能实现这一目标?
我想要这样的东西:
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:id="@+id/first_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="User Name:"/> <TextView android:id="@+id/second_label" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="bla bla bla"/> </LinearLayout>
或者像这样
<android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/first_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="User Name:" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent"/> <TextView android:id="@+id/second_label" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="bla bla bla" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toRightOf="@id/first_label" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"/> </android.support.constraint.ConstraintLayout>