Get phone orientation but fix screen orientation to portrait

前端 未结 7 1193
忘了有多久
忘了有多久 2020-12-01 09:09

I want to get the phone orientation but keep the screen orientation to portrait. So no matter the user turns the phone to landscape or portrait, the view stays the same, but

相关标签:
7条回答
  • 2020-12-01 10:02

    This is way simpler than writing a whole new class:

     final OrientationEventListener orientationEventListener = new OrientationEventListener( getApplicationContext() ) {
    
      @Override
      public void onOrientationChanged( final int orientation ) {
        Log.i("", "orientation = " + orientation );
      }
    };
    
    orientationEventListener.enable();
    
    0 讨论(0)
提交回复
热议问题