Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: Android
Hi Gurus,
I have some critical issue related to height of TextView. I want to set the height of the TextView based on the content which is set at runtime.
Here is my xml code:-
 < TextView
android:layout_height="wrap_content"/ >

Here is the java code to set the height of the TextView:-
TextView tv = (TextView) findViewById(;
int height_in_pixels = tv.getLineCount() * tv.getLineHeight();

But the problem is; it displays only 1 line, and not the rest of the lines.
Posted 7-Sep-10 3:04am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I'm having the exact same problem here.
Did you find a answer for yours?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 320
1 OriginalGriff 155
2 Peter Leow 115
3 Afzaal Ahmad Zeeshan 114
4 deepakdynamite 110
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,994
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514

Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 4 Oct 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100