ohadinho
ohadinho

Reputation: 7144

3 Dots after a text that not fit in to the textview 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 "Enter the text right over here" text to be written as "Enter the text right..." (because the text exceeds the width defined.

How can I create that functionallity ?

Upvotes: 4

Views: 8036

Answers (3)

Farid
Farid

Reputation: 2562

Deprecated:

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

In Use:

android:ellipsize="end"
android:maxLines="1"

Upvotes: 2

waqaslam
waqaslam

Reputation: 68187

set your textview as below:

<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"/>

Upvotes: 12

poitroae
poitroae

Reputation: 21377

Take a look at the ellipsize property.

Upvotes: 1

Related Questions