Truncate String In Android

913 Views

In this tutorial I will show you how to shorten your Strings in Android Studio( Example: My Title Is Long…). First import the Truncate Util

Step 1

import android.text.TextUtils;

Step 2
In your Activity initiate your TextView then set the following options

    message_desc.setSingleLine(true);
    message_desc.setEllipsize(TextUtils.TruncateAt.END);

An example in my case would be the following

TextView message_title = (TextView) rowView.findViewById(R.id.message_title);

message_title.setText("Large amount of text here");
message_title.setSingleLine(true);
message_title.setEllipsize(TextUtils.TruncateAt.END);

That’s it. Leave a comment and also follow us on Twitter @westernstudios


  1. Joselyn says:

    I was just looking at your website and see that your website has the potential to become very popular. Great job!

Please Post Your Comments & Reviews

Welcome to Western Studios

We provide professional website and mobile softwares including Joomla, Wordpress and more.