查找出来,如果​​Android设备是纵向还是横向的正常使用?纵向、正常使用、横向、设备

2023-09-04 09:28:35 作者:淼淼い嫣然

反正有没有发现,如果一个设备是纵向还是横向默认?在我的意思是,你通常是如何使用该设备。

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 normal usage but is there some flag for finding that out?

推荐答案

您可以做到这一点:

对于Lanscape

if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
    //Do some stuff
}

对于人像

if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
    //Do some stuff
}

检查:http://developer.android.com/reference/android/content/res/Configuration.html#orientation