Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.content.res.Configuration;

import android.util.DisplayMetrics;
import android.view.WindowManager;

public class Main {
    public static void fontsSize(Context context, float size) {
        Configuration configuration = context.getResources().getConfiguration();
        configuration.fontScale = size;
        DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        WindowManager wm = (WindowManager) context.getSystemService(context.WINDOW_SERVICE);
        wm.getDefaultDisplay().getMetrics(metrics);
        metrics.scaledDensity = configuration.fontScale * metrics.density;
        context.getResources().updateConfiguration(configuration, metrics);
    }
}