I have an Android app that needs some adjustment if the user sets their font size to extra large (via Settings -> Display -> Font size in 4.0 and higher).
Is there a simple way for me to tell what the user's font size preference is
Updated:
in my layout.xml I have lines similar to to setup a button
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:typeface="sans"
Notice that I'm not setting the font size directly. This layout works and looks good in all cases, except for the Extra Large setting. In that case, due to space limitations, it causes the button's text to wrap to 2 lines.
My goal is to make a slight wording change in the case of Extra Large so that it doesn't wrap
As always, it's best to pick a size for your body font first. Make sure it's large enough to read easily at an arm's length, but not too large—you don't want it to overwhelm the page. A good rule of thumb or body font size is 10-14 pt for print, 14-18 pt for screen.
1. Keep The Number of Fonts Used At a Minimum. Using more than 3 different fonts makes a website look unstructured and unprofessional. Keep in mind that too many type sizes and styles at once can also wreck any layout.
The font-size property is specified in one of the following ways: As one of the absolute-size, relative-size or math keywords. As a <length> or a <percentage> , relative to the element's font size.
There's a FONT_SCALE
parameter you should be able to query the system for. I haven't used it myself, but I imagine retrieving its value would look somewhat like this:
float fontScale = Settings.System.getFloat(context.getContentResolver(), Settings.System.FONT_SCALE)
However, I'd also like to point out that usually you shouldn't be dealing with this value directly. In stead, use sp
units for textual content so that you don't have to worry about adjusting to user-preferred font sizes yourself, but rather let the system handle that.
Also refer to: Why should we use sp for font sizes in Android?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With