问题
I did some researches about this question but I couldn't find my answer. So, yes I did create a folder under res called "layout-land" and I put a separate main.xml in it. I intentionally deleted some images in the main.xml in the layout-land and I noticed that these images were still there when I rotated the android phone to horizontal.
Many questions similar to mine are caused by adding onConfigurationChanged to manifest. But I did NOT add anything to manifest as explained by this link
layout-land xml files does not work with onConfigurationChanged call back
回答1:
First thing you must check is whether you already have in your Manifest.xml
android:configChanges="orientation"
that means that you wish to control the state of your activity when the orientation changes. When there's an orientation change Android will destroy your activity and recreate new, so any data will be lost.
So you should use onConfigurationChanged()
method or onRetainNonConfigurationInstance()
method.
I recommend to you read some tutorial.
来源:https://stackoverflow.com/questions/10807846/layout-land-is-not-working