Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to "truncate" a text inside textview in android according to the orientation?

I created a simple java function to truncate a string to be displayed in my list view. I am displaying a news title and below this a news summary. I would like to have the same behavior as the image below. Currently, i am truncating the news title with 45 chars and then appending "..." at the end of it. However, when I change the orientation to landscape, the title could appear without being truncated. I dont think the app below truncates the news title, but it keeps the title in a single line and automatically "truncates".

alt text

How can I achieve this behavior in my app?

like image 224
Thiago Avatar asked Nov 04 '10 13:11

Thiago


1 Answers

I don't think you need to truncate title manually. Android TextView component has ellipsize attribute that will do that for you. That also should adopt to any screen orientation.

like image 160
Konstantin Burov Avatar answered Nov 07 '22 09:11

Konstantin Burov