<android.support.constraint.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btn_at_the_start"
android:layout_width="0dp"
android:layout_height="45dp"
android:gravity="center"
android:text="Awards"
app:layout_constraintEnd_toStartOf="@+id/tv_in_the_middle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.2" />
<TextView
android:id="@+id/tv_in_the_middle"
android:layout_width="0dp"
android:layout_height="45dp"
android:ellipsize="end"
android:gravity="center"
android:textAlignment="center"
android:padding="5dp"
android:maxLines="2"
android:text="Nominations"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.6" />
<ImageButton
android:id="@+id/ibtn_at_the_end"
android:layout_width="0dp"
android:layout_height="45dp"
android:background="@android:color/transparent"
android:gravity="center_horizontal"
android:src="@drawable/ic_add_white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/tv_in_the_middle"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.2" />
</android.support.constraint.ConstraintLayout>
wrap_content
的宽度,我还添加了 app:layout_constrainedWidth="true"
和 app:layout_constraintWidth_max="wrap"
。 - eXactandroid:layout_width = "0dp"
android:layout_height = "wrap_content"
android:ellipsize = "end"
android:maxLines = "1"
app:layout_constraintEnd_toEndOf = "parent"
app:layout_constraintStart_toStartOf = "parent"
app:layout_constraintTop_toTopOf = "parent"
app:layout_constraintBottom_toOf = "parent"
您可以使用以下代码:
如下所示:
<TextView android:id="@+id/nomination"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@+id/someId1"
app:layout_constraintBottom_toBottomOf="@+id/someId2"
app:layout_constraintStart_toStartOf="@+id/awards"
app:layout_constraintEnd_toEndOf="parent"/>