Reputation: 12018
My application is in Portrait mode and it has one video view in it, on some events i want to rotate only the video view to landscape mode is it possible to do so?
From the code can we modify a single view to be of landscape mode as other will remain in portrait mode?
Also i have onOrientationChanged
listener in my activity which provides orientation
values as device orientation changes. how can i determine if device is in landscape or portrait mode from these values?
Upvotes: 0
Views: 1797
Reputation: 3268
Yeap, it's possible. You can get the orientation in runtime with this code:
Display display = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
//orientation will contain Configuration.ORIENTATION_PORTRAIT or Configuration.ORIENTATION_LANDSCAPE
int orientation = display.getOrientation();
So, if you want to make something when changing the orientation you can override the onConfigurationChanged
method.
And if you want to change the orientation in runtime you can use this (in example, change to portrait):
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
If want more details, read this
Upvotes: 1