Bug? Problem with layout not displaying correctly.

dealsmonkey

Active Member
Licensed User
Longtime User
Hi Everyone,

I have an intermittent issue, where a layout is not displaying correctly as you can see in the below image.

I am getting reports of this happening for both Android and IOS, but have been unable to recreate myself !!

Any thoughts would be appreciated.

Thanks in advance.

 

JohnC

Expert
Licensed User
Longtime User
It looks like the users have adjusted their system "default" font size to be larger then "Normal" as explained here:

https://www.b4x.com/android/forum/threads/user-adjusting-font-size-in-device-settings.38366/#content

The only fix is to force the font size of the views to a particular size, or try to reposition and resize your views so the text will still look good even if the user adjust the system font size. Or a mix-match of these two methods (some views having fixed size and others allow variance with system font size).
 

dealsmonkey

Active Member
Licensed User
Longtime User

Thanks for the reply, John. The problem is that this only happens occasionally to the users' device. When it happens, if they close and re-open the app, all is ok again! It is also happening in IOS aswell as Android
 

panagiotisden2

Active Member
Licensed User
Longtime User
I found some code in stackoverflow that changes that setting once your app launches and keeps it throughout the whole app.
If someone could translate it in B4A it would be great.
B4X:
//in base activity add this code.
public  void adjustFontScale( Configuration configuration) {

    configuration.fontScale = (float) 1.0;
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
    wm.getDefaultDisplay().getMetrics(metrics);
    metrics.scaledDensity = configuration.fontScale * metrics.density;
    getBaseContext().getResources().updateConfiguration(configuration, metrics);

}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    adjustFontScale( getResources().getConfiguration());
}
 

Gunther

Active Member
Licensed User
Longtime User
may be a conditional compilation and "#if JAVA .... #End if" helps to add that code: Inline Java Code
 

dealsmonkey

Active Member
Licensed User
Longtime User
Sorry for the late reply. Thanks, everyone for the comments.

I am using B4A 8.50. I added the font sizes into the start code as well and have not had reports of the issue since. Will wait and see what happens.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…