How do I disable orientation change on Android?

后端 未结 12 1011
一向
一向 2020-11-22 02:45

I have an application that I just would like to use in portrait mode, so I have defined android:screenOrientation=\"portrait\" in the manifest XML. This works OK for the HTC

12条回答
  •  北荒
    北荒 (楼主)
    2020-11-22 02:50

    In your androidmanifest.xml file:

       
    

    or

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    

提交回复
热议问题