简体   繁体   中英

how to fix orientation issues on android

I wanted to ask about android orientation; I made 2 different folders for layout: layout and layout-land when the orientation changes while the application is running i don't want to restart the running activity so i fixed that problem by adding the following line of the manifest file

android:configChanges="keyboardHidden|orientation|screenSize"/>

the problem then is that the app is not switching to the appropriate layout when i rotate the phone

does someone have any idea about the best way to handle the orientation changes of an android application ( i want to keep the state of the layout when i switch )

Simple: Let Android do the hard work.

Saying configChanges="orientation" overrides the default orientation behavior especially if you're using multiple layout files.

Change this:

android:configChanges="keyboardHidden|orientation|screenSize"/>

To this

android:configChanges="keyboardHidden|screenSize"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM