1. Are you ready for the Galaxy S20? Here is everything we know so far!

Adjust font size

Discussion in 'Android Development' started by SowmyaMistral, Jun 2, 2021.

  1. SowmyaMistral

    SowmyaMistral Lurker
    Thread Starter

    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?
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...