I have a tab activity that has three child activities, A, B and C. Child activities A and B are to follow the orientation of the tab activity. i.e. if the tab activity is in portrait so should A and B, if the tag activity is landscape so should A and B.
Child activity C should always be in landscape orientation regardless of the tab activity orientation (preferably following android:screenOrientation="sensorLandscape"). Is this possible?
I have tried using android:screenOrientation="sensorLandscape" for C in the manifest which doesn't work. The best I can manage is to use the following in C (in onResume())
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
and for A and B I use (also in onResume())
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
But this flips the entire tab which is not the effect I'm looking for.
I faced the same problem. Dont know if it is a good solution, but the workaround I found is as follows: Put
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
before thesetContentView()
ofonCreate()
method of Activity C. And putthis.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
before thesetContentView()
ofonCreate()
method of other two Activities (A and B).Any other elegant solution is highly appreciated.
I'm a newbie and all I can say is that the tab layout is very picky about what you do in it. try making it all landscape, then changing the orientarion of the two a/b tabs after C is working... good luck!
Use this in
AndroidManifest
: