Reputation: 2406
I have created an app with multiple tabs, each with its own layout. I have shut down response to the accelerometer to keep the app in portrait mode (android:screenOrientation="portrait").
Two of the tabs are designed in portrait mode, and one tab is designed in landscape mode. I need to take advantage of the fact that the screen is wider than it is high in landscape to display a mini spreadsheet.
Here is my question: How do I orient one of the tabs to landscape, while leaving the other two in portrait mode?
Any suggestions?
Upvotes: 2
Views: 1734
Reputation: 39470
not sure if you got an answer yet, but I've been searching for 30 mins and found a solution to a similar problem. Hope this helps.
I'm using tabhost and want 3 of 4 tabs to be able to rotate and 1 tab set to portrait mode only. Previously (before applying this fix) the 3 tabs would rotate until the fixed portrait tab was selected, then they were all stuck in portrait mode.
I had to set the other tabs to use the orientation of the USER to remedy this. i.e. added a setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
in the onResume of the other 3 tabs and it now works exactly as I had intended. 3 tabs will now rotate based on the user's orientation of the device, and 1 tab is fixed portrait. :)
Upvotes: 1
Reputation: 2406
I found a solution outside of the tab-set. The following link discusses multiple solutions for displaying Vertical text:
Vertical (rotated) label in Android
I went with "CustomTextView" by PocketMagic which can be found here: http://www.pocketmagic.net/?p=1625
With the ability to display vertical text, I can keep the entire tab-set locked in Portrait mode.
Thanks for the suggestions everyone.
-cc
Upvotes: 2
Reputation: 3282
To programmatically change orientation use setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); or setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);. In this case each tab click event could be tied to its relevant orientation
source: http://russenreaktor.wordpress.com/2010/01/03/solved-set-screen-orientation-programmatically/
Upvotes: 3