简体   繁体   English

如何设置几个片段是横向模式和休息应该是Android中的肖像?

[英]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.

相关问题 如何在 Android 中为横向和纵向模式设置单独的启动画面? - How can I set separate splash screens for landscape and portrait mode in Android? 如何在Android Libgdx中设置纵向的主屏幕和横向的其他屏幕? - How to set home screen in portrait and other screens in landscape in android Libgdx? 如何在Android中以人像模式在Fragment中实现QR码扫描仪? - How to implement QR code scanner in Fragment in portrait mode in android? 如何在横向和纵向模式下开始相同的活动? - How to start the same activity in landscape and in portrait mode? 如何使用libGDX在纵向和横向模式之间切换? - How to switch between portrait and landscape mode with libGDX? 如何以编程方式将我的Android应用程序锁定为纵向/横向模式? - How can I lock my android app into portrait / landscape mode programatically? 横向模式下的Android多片段布局 - Android multi-fragment layout in landscape mode 如何在代码中处理Android纵向和横向? - How to handle Android portrait and landscape in code? Android LinearLayout在横向和纵向模式下将元素放置在中间 - Android LinearLayout place elements in the middle with landscape and portrait mode 如何在Android OpenCV 3中将风景图像旋转为人像 - How rotate a Landscape Image to Portrait in Android OpenCV 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM