Get the real screen resolution on Ice Cream Sandwich

前端 未结 2 977
生来不讨喜
生来不讨喜 2021-01-02 03:46

Devices with Ice Cream Sandwich can use on-screen soft keys, and this means that some of the screen estate is taken by these keys. I need to get the real screen resolution,

2条回答
  •  孤街浪徒
    2021-01-02 04:05

    From API level 17 (Android 4.2 Jelly Bean), you can get the real size of the display as follows:

    Point size = new Point();
    Display display = getWindowManager().getDefaultDisplay();
    display.getRealSize(size);
    

    size will now contain the display size based on the orientation (ie. x will be left/right relative to the user, not the device)

提交回复
热议问题