The orientation of my activity is fixed to be landscape. I am inflating 3 different layouts in this activity over an GLsurface view Only one of this will be visible at a time depending on user actions. One of this layout is a video view. I would like to support both vertical and horizontal playing of video. But for all other views it need to be fixed to landscape. How can i achieve this .
Thanks for your time and help
In you AndroidManifest.xml activity declaration remove
android:orientation
tag & add
android:configChanges="keyboardHidden|orientation"
Now override below function in your activity
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig); //To change body of overridden methods use File | Settings | File Templates.
if (!isVideoViewSet)//change orientation to portrait other Views, skip for Video View
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
Here using some flag(isVideoViewSet in above code snippet) you can check which view is set and Set activity orientation accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With