取向的转变,我需要我的某些活动只更改为横向如果屏幕不够大。安卓:根据屏幕大小
这意味着平板电脑和手机与屏幕尺寸5.1in +。
反正通过覆盖onConfigurationChanged(...),并使用XML语句来做到这一点:
android:configChanges="orientation"
取向的转变,我需要我的某些活动只更改为横向如果屏幕不够大。安卓:根据屏幕大小
这意味着平板电脑和手机与屏幕尺寸5.1in +。
反正通过覆盖onConfigurationChanged(...),并使用XML语句来做到这一点:
android:configChanges="orientation"
你当然可以。您可以嗅出了屏幕尺寸和if语句,如果二进制或开关,否则设置手动视图的方向使用:
Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
screenWidth = (int)(d.getWidth());
screenHeight = (int)(d.getHeight());
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
不Display.getWidth()/ getHeight()返回像素大小? – bgroenks 2012-02-16 23:29:46
够公平: DisplayMetrics dm = new DisplayMetrics(); – 2012-02-17 00:54:06
mainContext.getWindowManager()。getDefaultDisplay()。getMetrics(DM) – 2012-02-17 00:56:46
我想你可以使用自己的“命名空间”,甚至为你的Manifest.xml – Cehm 2012-02-16 23:15:08