Skip to content Skip to sidebar Skip to footer

How To Determine The Height Of Textview Programmatically?

I have created an xml for a row of listview. It has just one Textview.

Or this

textview.getMaxHeight();

the maximum height of this TextView expressed in pixels, or -1 if the maximum height was set in number of lines instead using or setLines(int).

Solution 2:

Did you check this and this?

txtview.getHeight();

Returns The height of your view, in pixels.

Or

txtview.getLineHeight();

Returns the height of one standard line in pixels. Note that markup within the text can cause individual lines to be taller or shorter than this height, and the layout may contain additional first- or last-line padding.

Solution 3:

Solution 4:

I cannot find any answer to this question, so I am not accepting any answer provided so far on this thread. Since I am trying to calculate the height of the textview before it is rendered on the screen, by reading the xml layout, this is not supported in Android. In this case, we have to hard core the height measure and then convert this dp measure to pixel at runtime. Get the height of a TextView This link can be useful for others who are searching the answer for this.

Post a Comment for "How To Determine The Height Of Textview Programmatically?"