I have this XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
style="@style/Icon"
tools:background="@color/Black54Opacity" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="24dp"
android:ellipsize="end"
android:includeFontPadding="false"
android:maxLines="1"
android:padding="0dp"
android:textColor="@android:color/black"
android:textSize="20sp"
tools:text="LONG LONG LONG" />
<TextView
android:layout_width="wrap_content"
android:layout_height="18dp"
android:minWidth="18dp"
tools:text="2342"
tools:visibility="visible" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="24dp"
android:gravity="center_vertical|end"
android:textColor="4CAF50"
tools:text="EDIT" />
</LinearLayout>
</LinearLayout>
When I insert a short text in my first TextView - I haven't a problem.
When I insert a long text in my first textView - my second TextView moved under the third TextView.
I want the text in the first TextView can resize to that point so that the other two TextViews don't change their size.
The long text in the first TextView was ellipsized in the end. The second TextView must always be pressed against the left side of the first TextView.
We found a solution through the ConstraintLayout
.
LinearLayout
.app:layout_constrainedWidth="true"
in my first TextView. It's a very important attribute.