Question

My main activity is a TabActivity.

I have some activities presented by the tab activity which I want to lock to portrait orientation.

In AndroidManifest.xml when I set the screenOrientation property for any of the activities presented in the TabActivity it seems to be ignored for example:

   <activity android:name="FeedActivity"
              android:screenOrientation="portrait">
    </activity>

What is the most effective way of selectively disabling orientation changes with Tab Activities? Is it possible via the manifest?

This project is currently firmly pre-honeycomb. While I'm looking forward to being able to update it to API 11 and beyond I'm trying to find out if it is possible to address this problem without moving to fragments.

Was it helpful?

Solution

Do not use TabActivity, it's deprecated :)

Use TabHost with TabWdiget directly, with Activity

If you have content or tabs repeated over application you can use Fragments from compatibility package, there are good tutorial by link http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/

OTHER TIPS

For my case, I wanted ALL activities presented by the parent TabActivity to be locked in Potrait mode. Thus I only had to add

android:screenOrientation="portrait"

to my TabActivity. I did not need to add it to each individual child tab.

I went for this quick and dirty way because I plan to move the app to use Action Bar in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top