3 dots after text that does not match text size

I have this piece of code:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="100sp" android:orientation="vertical" android:id="@+id/linearLayout1"> <TextView android:id="@+id/click" android:layout_width="fill_parent" android:layout_height="30sp" android:text="Enter the text right over here" android:textSize="25sp" android:textColor="#000000" android:textStyle="bold" android:onClick="onClick" android:clickable="true"/> </LinearLayout> 

I need the text "Enter text right here", which will be written as "Enter text to the right ..." (because the text exceeds the specified width.

How can I create this property?

+4
source share
3 answers

set your text as follows:

 <TextView android:ellipsize="end" android:singleLine="true" android:id="@+id/click" android:layout_width="fill_parent" android:layout_height="30sp" android:text="Enter the text right over here" android:textSize="25sp" android:textColor="#000000" android:textStyle="bold" android:onClick="onClick" android:clickable="true"/> 
+12
source

Deprecated:

 android:ellipsize="end" android:singleLine="true" 

In use:

 android:ellipsize="end" android:maxLines="1" 
+2
source

Look at the ellipsize property.

+1
source

Source: https://habr.com/ru/post/1395817/


All Articles