Hi everyone,
One of the biggest challenges in UI/UX design for Android is when the user changes the Font Size (Acessibility) or Display Size (Scaling) in the system settings. This often breaks carefully designed layouts, especially when using fixed-size panels or labels.
This snippet, added to your Activity, forces the app to render at 100% font scale and uses the device's native density, ignoring system-wide overrides.
Add this to your Main Activity (or any Activity that needs to stay consistent):
One of the biggest challenges in UI/UX design for Android is when the user changes the Font Size (Acessibility) or Display Size (Scaling) in the system settings. This often breaks carefully designed layouts, especially when using fixed-size panels or labels.
This snippet, added to your Activity, forces the app to render at 100% font scale and uses the device's native density, ignoring system-wide overrides.
Add this to your Main Activity (or any Activity that needs to stay consistent):
B4X:
#If JAVA
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
@Override
protected void attachBaseContext(Context newBase) {
Resources res = newBase.getResources();
Configuration config = new Configuration(res.getConfiguration());
// 1. Fix Font Scale to 100% (Ignores "Large Text" settings)
config.fontScale = 1.0f;
// 2. Fix Density (DPI) to the device's native default
// This prevents "Display Size" changes from breaking layouts
config.densityDpi = res.getDisplayMetrics().densityDpi;
Context context = newBase.createConfigurationContext(config);
super.attachBaseContext(context);
}
#End If