What I want :
When text is short the 21% TextView
should be just beside the first TextView
like below
and when text is long I want the first TextView
to reach to end and ellipsize and 21% TextView
should be visible like below
but what ever I do the 21% TextView
goes away and first TextView
occupies complete space . I tried many combinations with Linear,Relative,Frame,Constraint layout,weight,minwidth etc but nothing seems to work.
Here is my xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_job_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce pulvinar nec justo id bibendum." />
<TextView
android:id="@+id/tv_matchPercent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:paddingLeft="5dp"
android:text="21% "
android:textColor="#4268e3"/>
</LinearLayout>
Any idea how to achieve it?
Note: I do not want to hard code characters or width
OUTPUT using ConstraintLayout
When Long Text
When Small Text
OUTPUT Using
FlexboxLayout
When Long Text
When Small Text
A solution using
LinearLayout
, of course it not better than usingContrainstLayout
or another way. However, hope it help in some situationTesting
input
Title 1111111111111111111111111111111
ouput
input
Title 1111111
ouput