你可以做下面这样的事情
在java中的rootView之后添加这一行
getActivity().setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // programmatically
对于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"
android:name="com.test.activity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden" >
博客针对android:screenorientation不起作用的问题给出解决办法。一是在Java的rootView后添加代码getActivity().setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);二是在manifest里修改android:configChanges属性,去掉orientation。
873

被折叠的 条评论
为什么被折叠?



