直接上代码:
public static void updateLocale(Context context, Locale locale) {
Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
if (configuration.locale.equals(locale))
return;
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
configuration.locale = locale;
resources.updateConfiguration(configuration, displayMetrics);
Resources.getSystem().updateConfiguration(configuration, displayMetrics);
}
本文详细介绍了如何在Android应用中使用Java代码直接修改资源文件的本地化设置,包括配置语言环境、更新显示尺寸等关键步骤。
4425

被折叠的 条评论
为什么被折叠?



