Reputation: 1129
I currently have a SurfaceView that is in Landscape mode.
Currently I am trying to add on an Action Bar/Menu Bar using
/*Action Bar */
//this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); **
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
Is there any way to leave the Action Bar in portrait mode on the screen while the SurfaceView is Landscape?
I have tried adding
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
but this makes the whole SurfaceView Portrait.
And then adding this
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
at the end would inf loop the program
Thanks
Upvotes: 1
Views: 518
Reputation: 2940
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
or LANDSCAPE
sets the orientation of the Activity, so you can't use it for the Surface View. If you want the ActionBar to be in portrait mode then you need to set the activity in Portrait, but figure out another way to set the SurfaceView to Landscape.
I would suggest for the SurfaceView to set the rotation of the Camera object, that way you will get the SurfaceView orientation in Landscape. Try the following:
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
camera.setDisplayOrientation(90);
Upvotes: 1