简体   繁体   English

android:screenOrientation =“ portrait”在豆形软糖中被忽略

[英]android:screenOrientation=“portrait” is ignored in Jellybean

android:screenOrientation="portrait" is ignored in Jellybean. android:screenOrientation =“ portrait”在Jellybean中被忽略。 If I turn the phone into landscape it will change orientation regardless. 如果我将手机转到横向,则无论如何它都会改变方向。 I have tried on several phones. 我已经尝试过几种手机。 Is there any new flag I have to use? 我需要使用任何新标志吗?

You can try to do it programmatically, 您可以尝试以编程方式进行操作,

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    switch (newConfig.orientation)
    {
    case Configuration.ORIENTATION_PORTRAIT:
        // taking action on event
        lockScreenRotation(Configuration.ORIENTATION_PORTRAIT);
    break;
    case Configuration.ORIENTATION_LANDSCAPE:
        // taking action on event
        lockScreenRotation(Configuration.ORIENTATION_LANDSCAPE);
    break;
    case Configuration.ORIENTATION_SQUARE:
        // taking action on event
        lockScreenRotation(Configuration.ORIENTATION_SQUARE);
    break;
    default:
        throw new Exception("Unexpected orientation!!!");
    break;
 }




private void lockScreenRotation(int orientation)
    {
      // Stop the screen orientation changing during an event
        switch (orientation)
        {
        ...
      case Configuration.ORIENTATION_PORTRAIT:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
      case Configuration.ORIENTATION_LANDSCAPE:
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
        ...
      case default:
       this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); 
       break;
        }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android:screenOrientation =“ portrait”在运行棉花糖的Nexus 5x上被忽略 - android:screenOrientation=“portrait” ignored on a Nexus 5x running Marshmallow Android模拟器-screenOrientation被忽略 - Android emulator - screenOrientation ignored android:screenOrientation =“ portrait”在一部中文键盘上不起作用 - android:screenOrientation=“portrait” is not working on one Chinese Pad 如何为相机设置android:screenOrientation =“ portrait” - How to set android:screenOrientation=“portrait” for Camera Android studio 3.6 给 android:screenOrientation="portrait" 划红线,需要更改 android:screenOrientation="fullSensor" 吗? - Android studio 3.6 give an redline for android:screenOrientation="portrait", need to change android:screenOrientation="fullSensor"? 锁定屏幕方向不是永久的(android:screenOrientation =“纵向”) - Locking screen orientation isn't permanent (android:screenOrientation=“portrait”) "Android Studio 升级后无法再使用 screenOrientation 肖像" - Can no longer use screenOrientation portrait after Android Studio upgrade 使用TabActivities忽略screenOrientation - screenOrientation ignored with TabActivities 即使指定了android:screenOrientation =“ portrait”,Android在景观中的启动活动(来自库项目) - Android starting activity (from library project) in landscape even when specified android:screenOrientation=“portrait” android:screenOrientation in manifest Portrait/lock 哪个是最好的以及它们之间的区别 - android:screenOrientation in manifest portrait/lock which one is best and difference between them
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM