Android: locale(system Language) change effect my

2019-01-29 06:04发布

问题:

i'm in my app, one activity is opened. I press home button and change language, from taskmanager opens my app. Problem: my activity layout is getting wide.

changes in androidmanifest corresponding to that activity:

Note: If i add locale in android manifest, layout is proper, but language is not getting updated immediately. User have to close that activity and then restart, only then language is getting updated.

Please provide me your inputs.

回答1:

As mentioned in the comment on your question, it is normal behaviour.

A change in Locale is considered a change of Configuration the same as a change in orientation etc.

You need to override onConfigurationChanged in your Activity and reload everything from there.

NOTE: You will also need to specify android:configChanges="locale" in the Activity declaration in the AndroidManifest file.