How to rotate views to portrait mode?
I have an application whose orientation is hard coded to landscape in the Manifest file. When the user presses options/menu on the application, the application launches a gridview/listview (depending on the option clicked). This works very well in the landscape mode. However, I run into problems if I want to change the UI when the user views the application in portrait mode. No matter what the mode the phone is in, the UIs are always displayed in landscape. (Because of the setting in the Manifest file). I tried doing a rotate animation (90 degrees), but that causes problems. For the list view, the scrolling does not work properly after the animation, and for the grid view, the clicks on the grid view elements correspond to the older layout 开发者_开发百科(landscape) and not the newer one (after rotate animation). Has anyone encountered this problem before? Any suggestions would be most welcome.
Try using the setRequestedOrientation
method on your activity:
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
精彩评论