[英]How to set few fragment be landscape mode and rest should be portrait in android?
I have an application in which activity and fragment, I have declared in the manifest for activity but for fragment I want landscape mode it working but after Java code all layout also changes in landscape mode I want on few fragment layout should be landscape and rest will be in portrait mode. 我有一个活动和片段的应用程序,我已经在清单中声明了活动但是片段我想要横向模式它工作但是在Java代码之后所有布局也在横向模式中改变我希望在几个片段布局上应该是横向和休息将处于纵向模式。
public class CustomizeFragment extends Fragment implements View.OnKeyListener, View.OnClickListener, StringConstants, BundleConstants, NetConstants, AlertDFragment.AlertListener {
private int mAlertIdentifier;
private String TAG = CustomizeFragment.class.getSimpleName();
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_customize, container, false);
// getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
getActivity().setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
init(rootView);
}
}
Before opening any fragment in landscape mode, you can change the orientation of the application by calling the below method in onclicklistener or so. 在横向模式下打开任何片段之前,您可以通过在onclicklistener中调用以下方法来更改应用程序的方向。
getActivity().setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
so that when application changes the fragment, it is adjusted. 这样当应用程序更改片段时,它会被调整。
添加在横向显示的所有片段“layout-land”文件夹以及在potrait模式下显示的所有片段“layout-port”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.