1

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.

madhead
  • 31,729
  • 16
  • 153
  • 201
Sandstone
  • 148
  • 2
  • 8

3 Answers3

0

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 the setContentView() of onCreate() method of Activity C. And put this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); before the setContentView() of onCreate() method of other two Activities (A and B).

Any other elegant solution is highly appreciated.

orchidrudra
  • 1,172
  • 1
  • 12
  • 30
0

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!

0

Use this in AndroidManifest :

<activity android:name=".YourClass" android:screenOrientation="portrait"></activity>
Mr.James
  • 376
  • 2
  • 8
  • 25
  • I've tried all variations of android:screenOrientation with the TabActivity and the child activities. I just cannot get a child activity to be in landscape orientation while the parent tab activity remains in portrait orientation. – Sandstone Jul 07 '11 at 21:16
  • Check it out , it might be useful: http://stackoverflow.com/questions/6557107/how-to-set-orientation-in-two-different-mode-in-two-layout/6557143#6557143 – Mr.James Jul 07 '11 at 23:17