1

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

Community
  • 1
  • 1
Solace
  • 8,612
  • 22
  • 95
  • 183

2 Answers2

3

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

Sandun Jay
  • 502
  • 2
  • 7
  • 23
  • Thank you for the answer, Is `12sp` the default size of the text for `TextView`? – Solace Dec 02 '14 at 07:47
  • 1
    There are three "default" textSize values: 14sp,18sp,22sp These are defined as the following TextAppearances - TextAppearance.Small - TextAppearance.Medium - TextAppearance.Large – Sandun Jay Dec 02 '14 at 07:54
  • Thank you again, but then what would be default TextAppearance? So that the sizes remain the same under all circumstances. – Solace Dec 02 '14 at 07:59
  • 1
    Default is 14sp. You can get default size by float size = new Button(this).getTextSize(); – Sandun Jay Dec 02 '14 at 08:01
  • Thank you indeed, Can you append this information in the answer as well, will be useful for somebody visiting in future. – Solace Dec 02 '14 at 08:05
1
Text size micro = 12sp.   
Text size small = 14sp.   
Text size medium = 18sp.   
Text size large = 22sp.   
Miki Franko
  • 687
  • 3
  • 7