• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Adjust font size

Hi All,

How can I prevent Font size changes from affecting the controls on my app?
I have tried the following
public void adjustFontScale(Configuration configuration)
{
if(configuration.fontScale > 1.3f) {
configuration.fontScale = 1.3f;
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);
}
}
I am able to override font size of the activity using above code. But I want just the header layout(containing button and textView) size to be controlled, not the entire activity. How do I achieve that?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones