setting screenOrientation to portrait doesn't work
you can do it something like below
After rootView in your java add this line
getActivity().setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // programmatically
For Ex:
View rootView = inflater.inflate(R.layout.activityxml, container, false);
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
And also in your manifest change it:
android:configChanges="orientation|keyboardHidden"
as
android:configChanges="keyboardHidden"
<activity
android:name="com.test.activity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden" >