Ga naar hoofdinhoud
Logo Appt Light

Bold text on Android

Apps should use bold text when users have indicated this as a preference in the system settings. Turning on bold text improves the contrast of the letters against the background, making the text easier to read. This is vital if you are visually impaired, but it can also be useful if you need reading glasses.

Op Android 12 is de fontWeightAdjustment eigenschap toegevoegd. Deze eigenschap geeft een waarde terug tussen de 1 en 1000. Een waarde van FontStyle.FONT_WEIGHT_BOLD (700) of hoger geeft aan dat de gebruiker een voorkeur heeft voor vette tekst.

fun Context.prefersBoldFont(): Boolean {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
        return false
    }
    return resources.configuration.fontWeightAdjustment >= FontStyle.FONT_WEIGHT_BOLD
}
Bijdragen

Feedback?

Laat 't ons weten!