What is the default text size on Android?
Solution 1
This will return default size of text on button in pixels.
Kotlin
val size = Button(this).textSize
Java
float size = new Button(this).getTextSize();
Solution 2
In general:
Three "default" textSize values:
- 14sp
- 18sp
- 22sp
These values are defined within the following TextAppearances:
- TextAppearance.Small
- TextAppearance.Medium
- TextAppearance.Large
More information about Typography can be found in the design guidelines
Related to your question:
If you don't set a custom textSize or textAppearance, TextAppearance.Small will be used.
Update: Material design:
New guidelines related to font and typefaces. The standard rule of 14sp remains (body).
Examples how to set textappearances
AppCompat version:
android:textAppearance="@style/TextAppearance.AppCompat.Body"
Lollipop and up version:
android:textAppearance="@android:style/TextAppearance.Material.Body"
Solution 3
Looks like someone else found it: What are the default font characteristics in Android ?
There someone discovered the default text size, for TextViews (which use TextAppearance.Small) it's 14sp.
Solution 4
Default values in appcompat-v7
<dimen name="abc_text_size_body_1_material">14sp</dimen>
<dimen name="abc_text_size_body_2_material">14sp</dimen>
<dimen name="abc_text_size_button_material">14sp</dimen>
<dimen name="abc_text_size_caption_material">12sp</dimen>
<dimen name="abc_text_size_display_1_material">34sp</dimen>
<dimen name="abc_text_size_display_2_material">45sp</dimen>
<dimen name="abc_text_size_display_3_material">56sp</dimen>
<dimen name="abc_text_size_display_4_material">112sp</dimen>
<dimen name="abc_text_size_headline_material">24sp</dimen>
<dimen name="abc_text_size_large_material">22sp</dimen>
<dimen name="abc_text_size_medium_material">18sp</dimen>
<dimen name="abc_text_size_menu_material">16sp</dimen>
<dimen name="abc_text_size_small_material">14sp</dimen>
<dimen name="abc_text_size_subhead_material">16sp</dimen>
<dimen name="abc_text_size_subtitle_material_toolbar">16dp</dimen>
<dimen name="abc_text_size_title_material">20sp</dimen>
<dimen name="abc_text_size_title_material_toolbar">20dp</dimen>
Solution 5
http://petrnohejl.github.io/Android-Cheatsheet-For-Graphic-Designers/
Text size
Type Dimension
Micro 12 sp
Small 14 sp
Medium 18 sp
Large 22 sp
Related videos on Youtube
Rene
Updated on July 08, 2022Comments
-
Rene almost 2 years
I have a mixture of Buttons and an own View, where I set my text size using Paint.setTextSize(). I want the text size to look the same like the text on the Button. Now, I can of course set the text size of the button to e.g. 18sp, and use 18 in my view. But for a better integration, I simply would like to know, what text size is "normal" for buttons. From my test, it should be something like 12sp, but I have not found any documentation on this.
Leaving the default sizes leaves way too small text on the view.
Maybe I should use still another approach to this issue?
-
Rene about 13 yearsWell, seems it is unkown. So I choose 16sp. This looks good enough, while not being too small (I need glasses already or a HTC HD :-) By the way, to scale the font for the graphics you need to find the scaling factor for your device first with float scale = getContext().getResources().getDisplayMetrics().density; Multiply this with your desired text size in sp, and set the size with Paint.setTextSize.
-
user207421 about 12 yearspossible duplicate of What are the default font caracteristics in Android?
-
Richard Le Mesurier about 5 yearsSearching the web for
abc_text_size_medium_material
(one of the standard size dimensions) gives the Material dimensions XML file from App Compat which contains all the standard sizes.
-
-
Ram Patra almost 10 yearsWould like to add to the above list,
12sp
forMicro
-
Andrew T. almost 10 yearsOn the other hand,
TextApperance.Micro
is actually non-existent. See this question -
Karsten about 9 yearsInterestingly, even in the Material theme the small/medium/large sizes are still 14/18/22 even though 18 and 22 aren't standard sizes as per the Material typography guide. Presumably this is for backwards compatibility.