We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
//是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 true, App 内的字体的大小将不会跟随系统设置中字体大小的改变 //如果为 false, 则会跟随系统设置中字体大小的改变, 默认为 false AutoSizeConfig.getInstance().setExcludeFontScale(true); 设置了以上代码在安卓14中更改系统字体,app内字体还是会跟着变大(改变),在安卓14以下设备则有效
2023-12-20 10:46:25.669 11621-11621 AndroidAutoSize com.yihubang.manager D designWidthInDp = 375, designHeightInDp = 812, screenWidth = 1440, screenHeight = 2900 2023-12-20 10:46:25.669 11621-11621 AndroidAutoSize com.yihubang.manager D initDensity = 3.5, initScaledDensity = 4.5499997 2023-12-20 10:46:26.203 11621-11621 AndroidAutoSize com.yihubang.manager D com.yihubang.manager.activitys.StartActivity used the global configuration. 2023-12-20 10:46:26.206 11621-11621 AndroidAutoSize com.yihubang.manager D The com.yihubang.manager.activitys.StartActivity has been adapted! StartActivity Info: isBaseOnWidth = true, designWidthInDp = 375.000000, designWidthInSubunits = 375.000000, targetDensity = 3.840000, targetScaledDensity = 3.840000, targetDensityDpi = 614, targetXdpi = 3.840000, targetScreenWidthDp = 375, targetScreenHeightDp = 733 2023-12-20 10:46:26.276 11621-11621 AndroidAutoSize com.yihubang.manager D com.yihubang.manager.activitys.StartActivity used the global configuration. 2023-12-20 10:46:26.278 11621-11621 AndroidAutoSize com.yihubang.manager D The com.yihubang.manager.activitys.StartActivity has been adapted! StartActivity Info: isBaseOnWidth = true, designWidthInDp = 375.000000, designWidthInSubunits = 375.000000, targetDensity = 3.840000, targetScaledDensity = 3.840000, targetDensityDpi = 614, targetXdpi = 3.840000, targetScreenWidthDp = 375, targetScreenHeightDp = 733 ---------------------------- PROCESS STARTED (11686) for package com.yihubang.manager ---------------------------- 2023-12-20 10:46:27.878 11621-11621 AndroidAutoSize com.yihubang.manager D com.yihubang.manager.activitys.AdminMainActivity used the global configuration. 2023-12-20 10:46:27.880 11621-11621 AndroidAutoSize com.yihubang.manager D The com.yihubang.manager.activitys.AdminMainActivity has been adapted! AdminMainActivity Info: isBaseOnWidth = true, designWidthInDp = 375.000000, designWidthInSubunits = 375.000000, targetDensity = 3.840000, targetScaledDensity = 3.840000, targetDensityDpi = 614, targetXdpi = 3.840000, targetScreenWidthDp = 375, targetScreenHeightDp = 733 2023-12-20 10:46:28.372 11621-11621 AndroidAutoSize com.yihubang.manager D com.yihubang.manager.activitys.AdminMainActivity used the global configuration. 2023-12-20 10:46:28.375 11621-11621 AndroidAutoSize com.yihubang.manager D The com.yihubang.manager.activitys.AdminMainActivity has been adapted! AdminMainActivity Info: isBaseOnWidth = true, designWidthInDp = 375.000000, designWidthInSubunits = 375.000000, targetDensity = 3.840000, targetScaledDensity = 3.840000, targetDensityDpi = 614, targetXdpi = 3.840000, targetScreenWidthDp = 375, targetScreenHeightDp = 733
//是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 true, App 内的字体的大小将不会跟随系统设置中字体大小的改变 //如果为 false, 则会跟随系统设置中字体大小的改变, 默认为 false AutoSizeConfig.getInstance().setExcludeFontScale(true);
在真机上,小米14(Android14)上面测试也是这个问题。 Android14还有一个问题就是 AutoSizeCompat.autoConvertDensityOfGlobal((super.getResources()));导致软键盘无法弹出。 删除以下代码解决了 @OverRide public Resources getResources() { //需要升级到 v1.1.2 及以上版本才能使用 AutoSizeCompat AutoSizeCompat.autoConvertDensityOfGlobal((super.getResources())); return super.getResources(); }
The text was updated successfully, but these errors were encountered:
找到解决办法了吗?现在setExcludeFontScale(true);无效
Sorry, something went wrong.
应用内有设置语言,然后在attachBaseContext里面设置fontScale为1,可以解决
在Activity内做如下调整可以解决
override fun attachBaseContext(newBase: Context?) { super.attachBaseContext(newBase) overrideFontScale(newBase) } private fun overrideFontScale(context: Context?) { context?:return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { context.resources.configuration.let { it.fontScale = 1f applyOverrideConfiguration(it) } } }
本质原因是Android14开始,字体缩放是非线性的,导致DisplayMetrics.scaledDensity这个方法失效,AutoSize在初始化字体缩放时失败。 改成用configuration.fontScale来设置就可以了
No branches or pull requests
Environment
Bug Description:
//是否屏蔽系统字体大小对 AndroidAutoSize 的影响, 如果为 true, App 内的字体的大小将不会跟随系统设置中字体大小的改变
//如果为 false, 则会跟随系统设置中字体大小的改变, 默认为 false
AutoSizeConfig.getInstance().setExcludeFontScale(true);
设置了以上代码在安卓14中更改系统字体,app内字体还是会跟着变大(改变),在安卓14以下设备则有效
Log:
Screenshot
Related Code:
Others:
在真机上,小米14(Android14)上面测试也是这个问题。
Android14还有一个问题就是 AutoSizeCompat.autoConvertDensityOfGlobal((super.getResources()));导致软键盘无法弹出。
删除以下代码解决了
@OverRide
public Resources getResources() {
//需要升级到 v1.1.2 及以上版本才能使用 AutoSizeCompat
AutoSizeCompat.autoConvertDensityOfGlobal((super.getResources()));
return super.getResources();
}
The text was updated successfully, but these errors were encountered: