Android Question System font size problem

Devv

Active Member
Licensed User
Longtime User
Hello

i am facing a weird problem with system font size

my app display a website in a webview

everything is working correctly if the system font is set to normal
if it is set to anything other than normal then stuff will go wrong


normal font
WhatsApp Image 2019-09-24 at 2.30.09 AM.jpeg


large font


WhatsApp Image 2019-09-24 at 2.e30.09 AM.jpeg




at first i thought the problem is from the website , it appeared that the system font change does not affect websites (on browser) so everything was running smooth when viewing the website from the browser


how could i possibly fix this issue ?
can i disable changing font size for my app ?

any ideas are highly appreciated
 
Upvote 0
You can add this code, based on the solution from that link, to your activity:
Code: Copy
#if Java
import android.content.*;
import android.content.res.*;
@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(newBase);
    final Configuration override = new Configuration(newBase.getResources().getConfiguration());
    override.fontScale = 1.0f;
    applyOverrideConfiguration(override);
   BA.Log("attachBaseContext");
}
#End If
It will be called. It has no effect based on my test with Android 10.

Resetting it programmatically: https://www.b4x.com/android/forum/threads/get-size-of-system-font-in-use.28065/#post-181853 (will not affect WebView)
 
Upvote 0
Curious, if you set system to Large font and view this same page in Chrome, what does it look like?
 
Upvote 0
You can add this code, based on the solution from that link, to your activity:
Code: Copy
#if Java
import android.content.*;
import android.content.res.*;
@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(newBase);
    final Configuration override = new Configuration(newBase.getResources().getConfiguration());
    override.fontScale = 1.0f;
    applyOverrideConfiguration(override);
   BA.Log("attachBaseContext");
}
#End If
It will be called. It has no effect based on my test with Android 10.

Resetting it programmatically: https://www.b4x.com/android/forum/threads/get-size-of-system-font-in-use.28065/#post-181853 (will not affect WebView)

it worked !

thank you bro
 
Upvote 0
Did you try adding the ChromeClient to the webview using webviewextras:
Code: Copy
wve.addWebChromeClient(wv, "WVE")
 
Upvote 0
You can add this code, based on the solution from that link, to your activity:
(...)
It will be called. It has no effect based on my test with Android 10.
About that Java Inline code, I managed to make it work.
The secret is to force finish the Activity and restart it again, so that the new setting is applied.
Attached a test project demonstrating this possibility.
The size of the texts is applied to the whole app and the new setting has effect on every text object, even MsgBoxes :)
... EXCEPT toast messages :(
 

Attachments

Last edited:
Upvote 0
About that Java Inline code, I managed to make it work.
The secret is to force finish the Activity and restart it again, so that the new setting is applied.
Attached a test project demonstrating this possibility.
The size of the texts is applied to the whole app and the new setting has effect on every text object, even MsgBoxes :)
... EXCEPT toast messages :(
Thanks a lot, it seems to work fine everywhere!
I'm not interested in the toast message!
 
Upvote 0
Back
Top