Android Question [solved] Android system setting for high-contrast fonts - how to detect?

Dave O

Well-Known Member
Licensed User
Longtime User
Can I detect if a device has the "High-contrast fonts" system setting enabled?

Some of my users reported that icons were not working correctly in my app, and I eventually discovered that they had turned on the Android "High-contrast fonts" accessibility setting. That feature changes text from a custom color to outlined black or white to make it more readable.

I use the Material and FontAwesome fonts to render icons in various colors, so this messed up my app.

I have now replaced those font icons with corresponding bitmaps (rendered on the fly), and that fixes things on some phones, but other phones (either newer Android versions or Samsung phones, haven't determined which yet) still convert those icon bitmaps to black or white, which is really annoying (and beyond the stated "high-contrast fonts" meaning).

Not sure if I can work around that, so I'm thinking that if I can detect the "high-contrast fonts" settings, I can at least inform users of the problem, and they can then decide if they want to turn it off themselves.

Any thoughts? Thanks!


B4X founder
Staff member
Licensed User
Longtime User
Apparently there is no public API for this. Try this:
Private Sub IsHighContrast As Boolean
        Dim ctxt As JavaObject
        Dim r As Reflector
        r.Target = ctxt.InitializeContext.RunMethod("getSystemService", Array("accessibility"))
        Return r.RunMethod("isHighTextContrastEnabled")
    End Try
    Return False
End Sub
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
Thanks Erel, that seems to work.

It turns out that this "high-contrast fonts" setting (introduced around Android 5 or 6) gets more aggressive in Android 9+, not only changing the rendering of text in buttons/labels/etc., but also overriding the rendering of canvas.drawText the same way.

I found a work-around on stackexchange that uses canvas.drawPath instead, and converted it to B4A. It seems to be working well on all Android versions I've tested so far.
Last edited:
Upvote 0