更新到 androidx.appcompat:appcompat:1.1.0 后的语言更改问题 [英] Language change issue after updating to androidx.appcompat:appcompat:1.1.0
问题描述
最新app-compat
的链接是1.1.0.
将我的应用升级到最新的 app-compat
后,我的语言设置在 API 24 以下的手机上停止工作(粗略地说,不适用于 API 21 及以下的手机)当然).
对于 API 24 及更高版本,我使用了 ContextWrapper
并设置了 locale
因此有效.
我的问题是如果 androidx.appcompat:appcompat:1.1.0
是稳定版本,为什么它在 alpha
和 beta中对我有用代码> 版本不同于这里的其他版本 &我试过的问题.
- 将 AppCompat 库更新为 appcompat 后:1.1.0-alpha03 语言环境配置不再起作用
- 迁移到 Androidx 后更改区域设置不起作用 -谈论 alpha 和 beta(我使用的是最新的稳定版本
1.1.0
)
是不是要等官方稳定版再降级最后一个稳定版本或者哪个是让谷歌的有效方式知道是否有(当然,我知道要提交错误)?
要继续使用 1.1.0 版,请在您的 attachBaseContext
下方添加:
Kotlin 解决方案:
override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) {如果(覆盖配置!= null){val uiMode = overrideConfiguration.uiModeoverrideConfiguration.setTo(baseContext.resources.configuration)overrideConfiguration.uiMode = uiMode}super.applyOverrideConfiguration(overrideConfiguration)}
Java 解决方案:
@Override公共无效应用覆盖配置(配置覆盖配置){如果(覆盖配置!= null){int uiMode = overrideConfiguration.uiMode;overrideConfiguration.setTo(getBaseContext().getResources().getConfiguration());overrideConfiguration.uiMode = uiMode;}super.applyOverrideConfiguration(overrideConfiguration);}
<块引用>
如果您不需要升级到最新的 appCompat
然后检查旧答案.否则使用@0101100101 提供的解决方案此处.
旧答案:
花了几个小时尝试后,才知道这可能是一个错误.
降级到最后一个稳定版本,它可以完美运行.
依赖项{implementation 'androidx.appcompat:appcompat:1.0.2'//************ 请勿在 API 23 及以下版本上升级语言问题 *********************//实现 'androidx.legacy:legacy-support-v4:1.0.0'....}
与此同时,我已经向 Google 提交了一个问题 https://issuetracker.google.com/issues/140880275
The link of the latest app-compat
which is 1.1.0.
After upgrading my app to the latest app-compat
my language settings stopped working for phones below API 24 (roughly, doesn't work on API 21 and below for sure).
For API 24 and above, I have used the ContextWrapper
and set the locale
hence works.
My question is if the androidx.appcompat:appcompat:1.1.0
is the stable version why does it work for me in alpha
and beta
versions unlike the others here & the questions which I have tried.
- After updating AppCompat library to appcompat:1.1.0-alpha03 Locale configuration is not working anymore
- Change Locale not work after migrate to Androidx - Talks about the alpha and beta (I am using the latest stable build
1.1.0
)
Should I wait for an official stable version again and downgrade to the last stable version or which is the efficient way to let google know if any(ofcourse, I know to file a bug)?
Edit:
To continue using version 1.1.0 add this below your attachBaseContext
:
Kotlin solution:
override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) {
if (overrideConfiguration != null) {
val uiMode = overrideConfiguration.uiMode
overrideConfiguration.setTo(baseContext.resources.configuration)
overrideConfiguration.uiMode = uiMode
}
super.applyOverrideConfiguration(overrideConfiguration)
}
Java solution:
@Override
public void applyOverrideConfiguration(Configuration overrideConfiguration) {
if (overrideConfiguration != null) {
int uiMode = overrideConfiguration.uiMode;
overrideConfiguration.setTo(getBaseContext().getResources().getConfiguration());
overrideConfiguration.uiMode = uiMode;
}
super.applyOverrideConfiguration(overrideConfiguration);
}
If you don't need to upgrade to the latest
appCompat
then check the old answer. Else use the solution provided by @0101100101 here.
Old Answer:
After spending hours trying, got to know that it might be a bug.
Downgrade to the last stable version and it works flawlessly.
dependencies {
implementation 'androidx.appcompat:appcompat:1.0.2' //************ DO NOT UPGRADE LANGUAGE ISSUE on API 23 and below *******************//
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
....
}
Meanwhile, I have filed an issue with Google https://issuetracker.google.com/issues/140880275
这篇关于更新到 androidx.appcompat:appcompat:1.1.0 后的语言更改问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!