Note that there are some explanatory texts on larger screens.

plurals
  1. POa layout with ellipsis then a counter
    text
    copied!<p>I'm new to Android, please help me to design below layout. Many thanks.</p> <p>I want to implement a layout, it shows a text followed by a counter. If the text is too long, show ... followed by counter. like below:</p> <p>Expected layout:</p> <p>Short text (3) // when screen width is enough </p> <p>Long text blah bl...(2) // when screen width isn't enough </p> <p>Below are my xml. It shows normally for above 1, when text is short. When text is long, the problem are: 1) it doesn't show "..." at the end of text 2) counter (2) isn't shown on screen.</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" &gt; &lt;TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="very long body safbadaf asfasf safasfd" android:layout_gravity="left" android:paddingLeft="4dp" android:paddingTop="8dp" android:paddingRight="4dp" android:paddingBottom="8dp" android:textStyle="bold" android:singleLine="true" android:ellipsize="end"/&gt; &lt;TextView android:id="@+id/count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="count" android:layout_gravity="center_horizontal" android:paddingLeft="4dp" android:paddingTop="8dp" android:paddingRight="4dp" android:paddingBottom="8dp" android:textStyle="bold" android:singleLine="true" android:layout_weight="1" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>William</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload