android:configChanges中单独添加locale,切换语言后Activity重启
16lz
2021-01-23
最近遇到一个问题,AndroidManifest.xml中配置了configChanges locale属性
android:configChanges="locale"
之后在不退出应用的情况下切换到Settings里切换语言,发现该Activity还是重启了。
看了网上(http://blog.sina.com.cn/s/blog_629712650101a1o3.html)的解释:4.2增加了一个layoutDirection属性,当改变语言设置后,该属性也会成newConfig中的一个mask位。所以ActivityManagerService(实际在ActivityStack)在决定是否重启Activity的时候总是判断为重启。
需要在android:configChanges 中同时添加locale和layoutDirection。
android:configChanges="locale|layoutDirection"
更多相关文章
- Android SystemProperties系统属性详解
- android RelativeLayout 适用场景和属性
- Android 禁止带有home属性的APP安装
- 布局动画 属性初始 android:animateLayoutChanges
- Android:Animation专题:1.alpha、scale、translate、rotate、set