【问题标题】:android portrait or landscape [duplicate]android纵向或横向[重复]
【发布时间】:2011-07-01 02:18:17
【问题描述】:

可能重复:
Check orientation on Android phone

如何以编程方式知道屏幕是纵向还是横向模式。请帮助我

【问题讨论】:

    标签: android


    【解决方案1】:
    if(context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) 
    {
        // code to do for Portrait Mode
    } else {
        // code to do for Landscape Mode         
    }
    

    【讨论】:

      【解决方案2】:

      【讨论】:

        【解决方案3】:

        getResources().getConfiguration().orientation

        或用于收听定向事件:http://android-developers.blogspot.in/2010/09/one-screen-turn-deserves-another.html

        或使用OrientationEventListener

        【讨论】:

          【解决方案4】:

          您可以检测当前的宽度和高度。如果高度大于宽度,则屏幕为纵向模式,否则为横向模式。

          【讨论】:

            猜你喜欢
            • 2015-09-09
            • 2016-12-15
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多