Take the 2-minute tour ×  I have a layout and a button in it. In
onCreate(), I calculate the size of layout and size of button
dynamically. Now based on the size (width) of the button I want
to set its TextSize. Initially the button textsize is set to 11,
but if the button size increases, the text looks very small. So
I need to increase the size of text also.  Is their any
method/way where I can calcualte the size of text and check with
that of the button size. Any ideas for appropriate method or
logic to be applied.  NOTE : I want to change the textSize of
button based on size of the button and not change buton size
based on textSize.  Any help is highly appreciated.
share|improve this question  1 Answer 1  up vote 1 down vote
accepted  If you get the paint for the button with getPaint()
you can use measureText() with your text to get the width the
text needs for a given setTextSize() setting. You may want to
experiment with some spair space.  There is code using to
concept for a different case in this ques