开发者

Differentiating between the two landscape modes

开发者 https://www.devze.com 2023-03-29 23:46 出处:网络
When rotating an Android device into Landscape mode, it can be in 2 different positions, from the device\'s perspective, the bottom buttons could be either on the left or on the rig开发者_如何学编程ht

When rotating an Android device into Landscape mode, it can be in 2 different positions, from the device's perspective, the bottom buttons could be either on the left or on the rig开发者_如何学编程ht. Is there a way to differentiate between these 2 modes? Either via onConfigurationChanged or via View.onSizeChanged I get the same result (obviously) as the device is on Landscape and the resolution is the same (800x480 in my case) for both "modes".

Thanks


This will get the screen orientation:

    Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int orientation = display.getRotation();

Then you can check it like this:

   if(orientation == Surface.ROTATION_90) {
      // do something
   } else if (orientation == Surface.ROTATION_270) {
      // do something else
   }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号