【发布时间】:2012-08-21 23:35:06
【问题描述】:
我创建了一个虚拟 Android 设备 480x800,运行它,并且我已经找到了如何更改屏幕 orientation (portrait-landscape, CTRL+F11/CTRL +F12/KP7/KP9),我用这些键来改变orientation。
但是当我尝试其中一个键时,虚拟屏幕旋转了 90 度,但方向没有改变。因此,按钮垂直放置在屏幕上,所有文本也是如此。就像一张旋转 90 度的图片。
如何让虚拟度数真正切换到另一个布局文件(/res/layout-land/activity_entry.xml)? Eclipse 的图形查看器确实在landscape/portrait 之间正确切换。
编辑
我在onCreateOptionsMenu(Menu menu) 下方的活动中添加了这一部分
方法,但应用程序无法识别屏幕方向变化:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Context context = getApplicationContext();
CharSequence text = "Orientation changed";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
编辑 2
当我从onCreate() 方法中调用this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) 时,它运行良好。
【问题讨论】:
-
我觉得是Ctrl+F11和Ctrl+F12,试试这个
-
Ctrl+F12,显然会起作用。 stackoverflow.com/questions/1991318/…
-
如果您在 android 清单文件中的活动中设置了 android:screenOrientation,请删除它
标签: android android-emulator screen-orientation avd