Android: child activity in landscape tab

I have a tab that has three child actions: A, B, and C. Child A and B for children should follow the orientation of the activity of the tab. that is, if the activity of the tab is in the portrait, so A and B, if the activity of the tag is landscape, so A and B.

The activity of child C should always be in landscape orientation regardless of the orientation of the activity of the tab (preferably after android: screenOrientation = "sensorLandscape"). Is it possible?

I tried using android: screenOrientation = "sensorLandscape" for C in a manifest that does not work. The best I can do is use the following in C (in onResume ())

this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 

but for A and B it is used (also in onResume ())

 this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 

But this flips the entire tab, which is not the effect I'm looking for.

+1
source share
3 answers

I'm a beginner, and all I can say is that the layout of the tab is very picky about what you do in it. try to make it all a landscape, and then change the orientation of the two a / b tabs after working C ... good luck!

0
source

Use this in AndroidManifest :

 <activity android:name=".YourClass" android:screenOrientation="portrait"></activity> 
0
source

I ran into the same problem. I don't know if this is a good solution, but the workaround I found is as follows: Put this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); to the setContentView() of onCreate() method for operation C. And add this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); before the setContentView() method of the other two actions (A and B).

Any other elegant solution is much appreciated.

0
source

All Articles