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
 

Devv

Active Member
Licensed User
Longtime User
Try to set Settings.SetTextZoom to 100 with WebViewExtras2.

B4X:
WebViewExtras.GetSettings.SetTextZoom(100)


hello

thanks for replay

i tried what you suggested but still the same result (nothing changed)
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can add this code, based on the solution from that link, to your activity:
B4X:
#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

JohnC

Expert
Licensed User
Longtime User
Curious, if you set system to Large font and view this same page in Chrome, what does it look like?
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
You can add this code, based on the solution from that link, to your activity:
B4X:
#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

JohnC

Expert
Licensed User
Longtime User
Did you try adding the ChromeClient to the webview using webviewextras:
B4X:
wve.addWebChromeClient(wv, "WVE")
 
Upvote 0

tagwato

Member
Licensed User
Longtime User
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

  • Test Override TextSize for the whole app.zip
    5.3 KB · Views: 156
Last edited:
Upvote 0

Luigi S

Active Member
Licensed User
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
Top