174

Does the documentation ( or anyone) talks about the dpi values of the default

  • Large TextView {android:textAppearance="?android:attr/textAppearanceLarge"}
  • Medium TextView {android:textAppearance="?android:attr/textAppearanceMedium"}
  • Small TextView { android:textAppearance="?android:attr/textAppearanceSmall"}

widgets in the SDK ?

The Large, medium, small and regular text views

To put it in another way, can we replicate the appearance of these text views without using the android:textAppearance attribute?

Jeff Lockhart
  • 5,379
  • 4
  • 36
  • 51
Vinay W
  • 9,912
  • 8
  • 41
  • 47
  • 1
    If you are using an intelliJ product such as Android Studio you will be able to view the documentation whenever you press F1 on the `android:textAppearanceValue` this will give you the size in sp/dp of the value. – androidtitan Sep 27 '17 at 18:20

3 Answers3

286

See in the android sdk directory.

In \platforms\android-X\data\res\values\themes.xml:

    <item name="textAppearanceLarge">@android:style/TextAppearance.Large</item>
    <item name="textAppearanceMedium">@android:style/TextAppearance.Medium</item>
    <item name="textAppearanceSmall">@android:style/TextAppearance.Small</item>

In \platforms\android-X\data\res\values\styles.xml:

<style name="TextAppearance.Large">
    <item name="android:textSize">22sp</item>
</style>

<style name="TextAppearance.Medium">
    <item name="android:textSize">18sp</item>
</style>

<style name="TextAppearance.Small">
    <item name="android:textSize">14sp</item>
    <item name="android:textColor">?textColorSecondary</item>
</style>

TextAppearance.Large means style is inheriting from TextAppearance style, you have to trace it also if you want to see full definition of a style.

Link: http://developer.android.com/design/style/typography.html

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
biegleux
  • 13,179
  • 11
  • 45
  • 52
19

To put it in another way, can we replicate the appearance of these text views without using the android:textAppearance attribute?

Like biegleux already said:

  • small represents 14sp
  • medium represents 18sp
  • large represents 22sp

If you want to use the small, medium or large value on any text in your Android app, you can just create a dimens.xml file in your values folder and define the text size there with the following 3 lines:

<dimen name="text_size_small">14sp</dimen>
<dimen name="text_size_medium">18sp</dimen>
<dimen name="text_size_large">22sp</dimen>

Here is an example for a TextView with large text from the dimens.xml file:

<TextView
  android:id="@+id/hello_world"
  android:text="hello world"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:textSize="@dimen/text_size_large"/>
Community
  • 1
  • 1
jfmg
  • 2,626
  • 1
  • 24
  • 32
9

Programmatically, you could use:

textView.setTextAppearance(android.R.style.TextAppearance_Large);
doctorram
  • 1,112
  • 14
  • 13