Today's #AndroidDev #Protip on text appearance and theme attributes is by +Katherine Kuan, the newest member of Android Developer Relations (welcome, Katherine!)
When choosing font sizes for your app, using too many different sizes can be visually distracting and confuse the user as to what information is important. To be consistent with other apps on the platform, you can use the standard set of type sizes provided by the framework: small, medium, or large.
To use a standard text size (and color), instead of setting the TextView's android:textSize
directly, set the android:textAppearance
to a predefined theme attribute  such as android:textAppearanceLarge
… android:textAppearance="?android:textAppearanceLarge" />
As of API 19 (KitKat):
is currently 14sp
is currently 18sp
is currently 22sp
These default sizes and concepts are also documented in the "Typographic scale" section of the Android Design guide .
Note that setting the text appearance will also affect the default values for text color attributes such as android:textColor
. You can always override the default values by providing those attributes directly on the TextView element:<TextView
... android:textAppearance="?android:textAppearanceLarge" android:textColor="@color/my_own_color" android:textColorLink="@color/my_own_link_color"/>
Also note that you don't necessarily have to use the system default appearances. You can create your own set of type sizes and colors that fits your desired visual design. For information on creating your own theme attributes, see the #Protip
we posted on the topic back in October .
Lastly, if you want to check out the definition of these standard text appearances in the framework code, look for "textAppearanceLarge" in the Theme.Holo
) definition in themes.xml
. The attribute values will be style resources (such as TextAppearance.Holo.Large
), for which you can find definitions in styles.xml
. In the example above, note that TextAppearance.Holo.Large
inherits from TextAppearance.Large
, which in turn inherits from the standard TextAppearance