Android TextView in one line -


there code below. need obtain result on snipset:

when short string:

1 line:  abc (123) 

when long string:

1 line:  abc abc abc abc abc...(123) 

any help?

<linearlayout     android:orientation="horizontal"     android:layout_width="match_parent"     android:layout_height="match_parent">      <textview         android:id="@+id/id1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textstyle="bold"         android:ellipsize="end"         android:maxlines="1"         android:visibility="visible"         android:text="abc abc abc abc abc abc abc abc abc abc abc abc"         android:textsize="@dimen/text_size_form"/>      <textview         android:id="@+id/id2"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:visibility="visible"         android:ellipsize="end"         android:maxlines="1"         android:text="123"         android:textsize="@dimen/text_size_form"/>  </linearlayout> 

you can check string length, if longer specific length, can display want.

ex. max length want 20

if (str.length()>20) {     str = str.substring(0, 20)+"...";  } 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -