I used this code:
Rect bounds=new Rect();
tv.getPaint().getTextBounds(text,0, text.length(),bounds);
float textWidth=bounds.width();
float textHeight=bounds.height();
and it works well horizontally... also vertical size is ok... but the text is painted in a position lower than what I expect...
these links was not useful:
auto scale textview text to fit within bounds
what should I change?