Reputation: 2636
I need to show a Large text view in android,if the string length is small i want to show the whole text if the String length is high I want to show the texts in first the letters of the String followed by dots and then followed by the last part of the String.
Like if the String is 'Google' i want to show "Google" If the String is 'Google Play Developer Console' I want to show the String something like "Google P...Console" how can I achieve this?
Upvotes: 2
Views: 1443
Reputation: 3585
if(string.length() <= 5)
{
tvAdd.setText(yourstring);
}
else
{
tvAdd.setText(yourstring.substring(0, 5) + "..");
}
Upvotes: 0
Reputation: 14226
Use ellipsize
to abbreviate the text:
<TextView android:layout_width="50dp"
android:layout_height="match_parent"
android:singleLine="true"
android:ellipsize="middle"/>
Upvotes: 2