Reputation: 1887
i want to change layout without calling the onCreate method. i also define android:configChanges="orientation|keyboardHidden" in my activity and it is not calling the onCreate method but the layout not adjust appropriately on landscape mode.
my current layout look like as follows.
after change orientation as landscape it look like as follows:
but on landscape i want the following result.
is there any auto adjacent property?
how can i do it?
Upvotes: 6
Views: 11022
Reputation: 349
Put this in your manifest bro..
android:configChanges="orientation|keyboardHidden|screenSize|uiMode"
It's solve your and my problem :D
Upvotes: 0
Reputation: 11
You only put this android:configChanges="orientation|keyboardHidden" in your activity tag in android manifest.it works.
Upvotes: 0
Reputation: 11
You could add android:configChanges="orientation"
to Activity tag on AndroidManifest.xml.
Try it.
Upvotes: 1
Reputation: 2898
See this documentation th handle this
http://developer.android.com/resources/articles/faster-screen-orientation-change.html
Upvotes: 1
Reputation: 16339
there is no auto adjust property while view changes from portrait to landscape.
For images that you want to display in landscape mode
Create one filename.xml file and design your layout for landscape mode. Give filename same as your previous xml file in layout folder that you are using for activity.
Create folder in res/ name as layout-land and then keep that filename.xml file in res/layout-land folder
It will automatically call that res/layout-land/filename.xml when orientation changes from portrait to landscape.
Or you can also use
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
//your code
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
//your code
}
}
Upvotes: 4
Reputation: 21
I'm going to assume you're using a LinearLayout, because you didn't specify, but there's a function in the LinearLayout class called setOrientation() that should fix this. You'll have to create an instance of your layout in your java file (which you may have already done) and then create either an orientationchange or resize event listener on your window. After that it's just changing the orientation to horizontal/vertical based on screen orientation.
Upvotes: 0