Reputation: 1924
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.
Upvotes: 0
Views: 195
Reputation: 360
Check the orientation and request to change it:
if (getResources().getConfiguration().screenOrientation != (Configuration.ORIENTATION_LANDSCAPE|Configuration.ORIENTATION_POTRAIT)) {
getActivity().setRequestedOrientation(Configuration.SCREEN_ORIENTATION_LANDSCAPE);
} else {
}
Open for correction, as always! Regards, Edward Quixote.
Upvotes: 1
Reputation: 991
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.
Upvotes: 1