Possible Duplicate:
Android - disable landscape mode?
I can't s开发者_Go百科ave position of view when orientation changes. I think it's because with orientation it also changes and I want that view stayed on the same position. For example of it was in the upper left corner of screen it stayed there and it doesn't matter what orientation of the device. I'm using some kind of Absolute layout. Because I need to manage few screens at the same time. So, i have x/y coordinate system. I think it's the main problem, but I can't solve it :(
I've attached images that you could see my problem. As you can see first screen is portrait mode and View is located in upper-left corner, but when I changed to landscape mode position of view is also changed to upper-right corner. And I need that position of view stayed always in left-upper corner.
- http://imgur.com/qo19E&u2K0hl
- http://imgur.com/qo19El&u2K0h
Sorry to bad screen. I'm still developing of an application and can't provide better screens :)
Ps: If you need some code, just say what part of code do you need.
Duplicate of Android - disable landscape mode?
You can force the activity to run in a particular orientation. Inside the AndroidManifest.xml use the attribute "android:screenOrientation"
See here for an example: http://developer.android.com/guide/topics/manifest/activity-element.html
It would be nice if you could provide some code or screenshots.
Anyway, when the orientation changes, your activity is destroyed and recreated. If you have a well designed xml layout file (using linearlayout, relativelayout and properties like "wrap_content", "fill_parent"...) it will reload it in the onCreate() method, so all the resizing should be done automatically.
If your views can be moved by the user or are loaded from runtime values, you can save it. Look at this post for exemple : Override Orientation Change But NOT Restart The Activity AND Pass State Data
精彩评论