i have a text called Hello
now i need to apply fontsize for this say 12 or 18 now as soon as we apply font to the text the text size increases.
so now i need to get the text height including the font size using paint.
i have tried with paint the following:
String finalVal ="Hello";
Paint paint = new Paint();
paint.setTextSize(18);
paint.setTypeface(Typeface.SANS_SERIF);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.FILL);
Rect result = new Rect();
// Measure the text rectangle to get the height
paint.getTextBounds(finalVal, 0, finalVal.length(), result);
But its not working , please help
EDIT
i am trying to set the height of webview dynamically based on the textheight i am getting the text height for single line like "Hello"
but if there are two lines in the text "My name is abc and my dads name is xyz and my moms name is 123" now its not getting the proper text height".