Android determine screen orientation at runtime

后端 未结 6 906
清酒与你
清酒与你 2021-02-01 05:41

Here\'s a pseudo code to detect screen rotate event, and decide to retain or changes the screen orientation.

public boolean onOrientationChanges(orientation) {
          


        
6条回答
  •  我在风中等你
    2021-02-01 05:46

    Another solution to determine screen orientation:

    public boolean isLandscape() {
        return Resources.getSystem().getDisplayMetrics().widthPixels - Resources.getSystem().getDisplayMetrics().heightPixels > 0;
    }
    

提交回复
热议问题