作者:Yogi
前言:在项目中遇到一个问题,当在设置中切换语言成功后回到Lanucher时,Lanucher会走onDestroy方法,从而界面会出现白屏现象,这显然是不好的,下面给出解决办法。
在主Activity中加入
android:configChanges=”locale|layoutDirection”
就能够达到语言切换,而不需重启Launcher的目的,从而,也就不会走onDestroy方法,也就不会白屏。
具体写法如下
<activity
android:name="包名.XXActivity"
android:launchMode="singleTask"
android:label="@string/app_name"
android:configChanges="locale|layoutDirection"
>