Search code examples
androidandroid-fragmentsscreen-orientationfragment-tab-host

How to rotate a particular fragment activity using tabhost in android


I have implemented tabhost with fragments in my project and in a particular tab I have implemented a fragment activity, the same activity I need it in both the orientation landscape and portrait but I can't do this.

When I rotate this activity with the below code, the rest of all tabs with fragments automatically changed into the landscape mode.

android:screenOrientation="unspecified"

Your additional efforts will be highly appreciated.


Solution

  • you need to specify screenorinetation to the parent activity not the individual activity.

    For example Suppose you have 3 Fragments and those 3 fragmnets attached to a Parent activity called ParentA

    now in your manifest under the activity field of ParentA specifiy screenorientation="unspecified".You don't need to specify individual activity screenorientation specified to the various fragment.