📜  在 android studio 中调整字体比例 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:43.499000             🧑  作者: Mango

代码示例2
private fun adjustFontScale(configuration: Configuration) {
        if (configuration.fontScale > 0.90) {
            configuration.fontScale = 0.90f
            val metrics = resources.displayMetrics
            val wm = baseContext.getSystemService(WINDOW_SERVICE) as WindowManager
            wm.defaultDisplay.getMetrics(metrics)
            metrics.scaledDensity = configuration.fontScale * metrics.density
            baseContext.resources.updateConfiguration(configuration, metrics)
        }
    }