小编pra*_*hat的帖子

反应本机道具allowFontScaling在android上不起作用

我是反应原生的新手,想要修复应用程序所有屏幕中的文本大小,如果我从设备设置中增加文本大小,那么字体大小也应该与我尝试过的相同:

Text.defaultProps.allowFontScaling=false;
Run Code Online (Sandbox Code Playgroud)

在 android.index.js 和

public void adjustFontScale(Context context, Configuration configuration) {
    configuration.fontScale =(float) 0.85;
    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);

}
Run Code Online (Sandbox Code Playgroud)

oncreate()在 mainactivity.js之后调用super.onCreate();

并且从 AndroidManifest.xml 链接的自定义主题也不起作用

如果有人对此有其他解决方案,请帮助我。

它在 ios 设备上完美运行。

android android-layout android-activity react-native react-redux

1
推荐指数
1
解决办法
7584
查看次数