Click here to Skip to main content
12,550,447 members (45,955 online)
Rate this:
Please Sign up or sign in to vote.
See more: Mobile 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 2: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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 4 Oct 2010
Copyright © CodeProject, 1999-2016
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