Handling Screen orientation in android -
this app requires both portrait , landscape orientations. here creating "layout-land" folder in resource folder landscape orientation.while doing orientation activity taking xml "layout-land" activity restarting.
so avoid restarting,in manifest using following permissions:
<android:configchanges="keyboardhidden|orientation|screensize"> while using above permissions activity not restarting unable take xml "layout-land" folder.
here need:
1. avoid restarting activity
2. making activity take xml "layout-land" folder. new android.please me in this.thanks in advance.
that's way android works. need choose 1 of 3 options:
use exact same layout portait , landscape; then, can use
configchangesabove. can work if have few minor changes, if can keep majority of layout same , make few items visible/invisible based on orientation.use different layouts; then, can keep
configchanges, have implement loading of new layout inonconfigurationchanged, including taking values old views , adding them new (anything set @ run time: text values, user entered edit texts, check box states, etc).remove
configchangeline manifest, , implementonsaveinstancestate,onrestoreinstancestate. these 2 give chance save values want , restore them around restart of activity. same two, don't have manually reset view.
i highly suggest 1 if @ possible. if must use landscape specific layout, going route 3 easiest. i'm big fan of setting configchanges, doesn't work if need different landscape layout.
Comments
Post a Comment