Ramesh Solanki
Ramesh Solanki

Reputation: 383

Truncating contents of Android TextView to fit width

how can i find the number of character fit into the textview of android. if suppose textview can fit only 25 character so i can get the substring from 0,25 and assign to textview. so is it possible ? thanx in advance

Upvotes: 1

Views: 627

Answers (1)

Yoni Samlan
Yoni Samlan

Reputation: 38065

TextViews natively support automatically clipping their contents using the ellipsize property; setting the maxLines (or singleLine) on the TextView and adding android:ellipsize="end" will probably get the effect you're looking for without you having to muck about with substring operations yourself.

Upvotes: 3

Related Questions