Home > Android > Truncating text in a TextView or ListView

Truncating text in a TextView or ListView


You will often find yourself loading text into a ListView and, as it is too long for the line, it wraps around. To resolve this solution you can use a combination of parameters in your layout file.


The two main parameters are:

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

Using a TextView element as an example, you would include these parameters as follows:

    <TextView
            android:id=”@+id/tvw_name”
            android:layout_width=”wrap_content”
            android:layout_height=”wrap_content”
            android:ellipsize=”end”
            android:singleLine=”true”
   />
Categories: Android
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: