2013-02-12 80 views

回答

1

使用方法check whether the device is a tablet,然后force orientation如果它是真的。

// From https://stackoverflow.com/questions/5832368/tablet-or-phone-android 
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); 
} 

// ... 

// Do this from any Activity you do not wish to rotate on tablets: 
if (isTablet(this)) 
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
+0

AFAIK有在预期这些指令不工作的设备,他们一直等待的意见进行设置,等等 – Frank 2013-02-13 07:09:21

+0

“等待即将成立的意见”?我不确定你的意思。只要你在'setContentView()'之前这样做了,它就没有等待的视图。 – Eric 2013-02-13 14:36:37

相关问题