Android: How to make the text size of Borderless button same as that of TextView

454 views Asked by At

In the following two images, there are four widgets in a horizontal linear layout:

  1. A TextView with the text Results:
  2. A Borderless Button with the text My Cat
  3. A View which is a hack for a "Vertical Separator"
  4. A Borderless Button with the text My Dog

Two questions:

  1. Results: in the first one is bold because I used the <b> tag around it in the string resources file. But I used the <strong> tag in the second one, which does not make it bold.

    I did read that strong has semantic meaning, so that may be a screen reader for blind people will read it in different tone, for blind people. But visually, it should be bold, isn't it?

  2. I want the text in the Buttons to be of the same size as the TextView. I believe for that I need to get the text size of the TextView (or the default size in the Android system? or "default size" is something on the user's device? :s ) in sp (because sp is also scaled by the user's font preference) and then set the text size of the button same as that? How can I do that?

Can I do it in XML? or is it just possible programatically? and how?

enter image description here

enter image description here

2

There are 2 answers

5
Sandun Jay On BEST ANSWER

Use android:textStyle="bold" for bold text and android:textSize="12sp" for change text size of button in your xml.

0
Miki Franko On
Text size micro = 12sp.   
Text size small = 14sp.   
Text size medium = 18sp.   
Text size large = 22sp.