Find out if Android device is portrait or landscape for normal usage?

前端 未结 8 1570
情话喂你
情话喂你 2020-12-07 22:05

Is there anyway to find out if a device is portrait or landscape by default? In that I mean how you normally use the device.

Most phones have a portrait screen for

8条回答
  •  没有蜡笔的小新
    2020-12-07 23:04

    It's simple, Just a If-Else block:

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        // landscape
    } else {
        // portrait
    }
    

提交回复
热议问题