Android Question System font size problem

Devv

Active Member
Licensed 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
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)
 

Erel

Administrator
Staff member
Licensed 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)
 

JohnC

Well-Known Member
Licensed User
Curious, if you set system to Large font and view this same page in Chrome, what does it look like?
 

Devv

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

JohnC

Well-Known Member
Licensed User
Did you try adding the ChromeClient to the webview using webviewextras:
B4X:
wve.addWebChromeClient(wv, "WVE")
 
Top