强制一个机器人活动总是使用横向模式横向、机器人、模式

由网友(王予冠首)分享简介:我是用我的G1的Andr​​oid VNC查看器。但由于某些原因,始终是应用在横向模式下,尽管我的G1是在纵向模式。由于Android VNC查看器是开源的,我想知道,怎么可能很难code的活动是'景观'。我想改变它尊重了手机的方向。 I am using android vnc viewer on my G1. B...

我是用我的G1的Andr​​oid VNC查看器。但由于某些原因,始终是应用在横向模式下,尽管我的G1是在纵向模式。由于Android VNC查看器是开源的,我想知道,怎么可能很难code的活动是'景观'。我想改变它尊重了手机的方向。

I am using android vnc viewer on my G1. But for some reason, that application always in landscape mode despite my G1 is in portrait mode. Since android vnc viewer is open source, I would like know how is it possible hard code an activity to be 'landscape'. I would like to change it to respect the phone orientation.

感谢你。

推荐答案

纵观AndroidManifest.xml中(link),第9行:

Looking at the AndroidManifest.xml (link), on line 9:

<activity android:screenOrientation="landscape" android:configChanges="orientation|keyboardHidden" android:name="VncCanvasActivity">

该行指定 screenOrientation 景观,但笔者更进一步的覆盖所有屏幕方向的改变与 configChanges =定位| keyboardHidden。这表明在VncCanvasActivity.java一个重写的功能。

This line specifies the screenOrientation as landscape, but author goes further in overriding any screen orientation changes with configChanges="orientation|keyboardHidden". This points to a overridden function in VncCanvasActivity.java.

如果你看一下VncCanvasActivity,上线109是overrided功能:

If you look at VncCanvasActivity, on line 109 is the overrided function:

@Override
public void onConfigurationChanged(Configuration newConfig) {
  // ignore orientation/keyboard change
  super.onConfigurationChanged(newConfig);
}

笔者专门整理了评论忽略任何键盘或方向改变。

The author specifically put a comment to ignore any keyboard or orientation changes.

如果你想改变这一点,你可以回到上面显示的Andr​​oidManifest.xml文件,并更改该行:

If you want to change this, you can go back to the AndroidManifest.xml file shown above, and change the line to:

<activity android:screenOrientation="sensor" android:name="VncCanvasActivity">

这应该改变计划,从纵向切换到横向当用户旋转设备。

This should change the program to switch from portrait to landscape when the user rotates the device.

这可能工作,但可能会陷入困境如何GUI看起来,这取决于布局是如何创建的。你必须考虑到这一点。此外,根据不同的活动如何为codeD,您可能会注意到,当屏幕方向改变时,即填充到任何输入框中的值消失。这还可能要被处理

This may work, but might mess up how the GUI looks, depending on how the layout were created. You will have to account for that. Also, depending on how the activities are coded, you may notice that when screen orientation is changed, the values that were filled into any input boxes disappear. This also may have to be handled.

阅读全文

相关推荐

最新文章