Android锁屏旋转

时间:2014-01-31 20:24:47

标签: android rotation

我知道我可以在清单中的活动的xml标签中将屏幕布局设置为纵向或横向,以防止屏幕旋转。

我有一个可以在手机和平​​板电脑上运行的应用。在平板电脑上,我希望有风景,在手机上我想有肖像模式。我该怎么做这个配置? (当然,当设备旋转时,屏幕不得)。

1 个答案:

答案 0 :(得分:0)

要检查它是否为选项卡,您可以使用以下简单方法:

public boolean isTablet(Context context){
boolean xlarge = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == 4);
boolean large = ((context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
return (xlarge || large);
}

OR

      public static boolean isTablet(Context context) {
      return (context.getResources().getConfiguration().screenLayout
        & Configuration.SCREENLAYOUT_SIZE_MASK)
        >= Configuration.SCREENLAYOUT_SIZE_LARGE;
      }

两者都对你有帮助。

有关详细信息,请查看此conversation.