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

1

5

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?

Siebert answered 4/11, 2010 at 13:44 Comment(0)
E
7

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.

Edda answered 4/11, 2010 at 13:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.