Android 2.3 中的方向没有改变
我创建了一个应用程序,需要支持景观和景观肖像模式。
为此,我在 layout 文件夹中设置了纵向布局,在 layout-land 文件夹中设置了横向布局。在 android 2.3.1 模拟器中,当我运行应用程序然后第一次打开纵向模式时,我会更改方向 横向并更改布局,但当再次更改模式时,模拟器会更改为纵向模式,但布局不会更改,而是使用横向布局。 毕竟我尝试了这个方法。
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
或
清单文件中的 android:configChanges="orientation|keyboardHidden"
。但没有效果。请帮助我。谢谢
I have created an application, Which required to support landscape & portrait mode.
For that, I have set portrait layout in layout folder and landscape layout in layout-land folder. In android 2.3.1 simulator when i run application then first time open portrait mode i change orientation then
landscape and change layout but when again change mode then simulator change in portrait mode but layout is not change it is used landscape layout.
After all this i tried this method.
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
or
android:configChanges="orientation|keyboardHidden"
in manifest file. but no effects. Pls help me. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该版本的模拟器存在一个错误,有时它不会拾取旋转更改
编辑:无论如何对我来说都是如此>_>并且在手机上运行良好,我想我在来源之前读过这个
: http://groups.google.com/group/android-developers/browse_thread/thread/141c1b1ba937e7a7
http://code.google.com/p/android/issues/detail?id=13193&q=emulator%20rotate&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
:)
There is a bug with that version of the emulator and it doesn't pick up rotation changes sometimes
edit: does for me anyway >_> and works fine on phones, and I THINK i've read this somewhere before
source: http://groups.google.com/group/android-developers/browse_thread/thread/141c1b1ba937e7a7
http://code.google.com/p/android/issues/detail?id=13193&q=emulator%20rotate&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
:)
http:// /www.southparksystems.com/devzilla/2010/3/3/switching-layouts-when-screen-orientation-changes-in-android.html
http://www.southparksystems.com/devzilla/2010/3/3/switching-layouts-when-screen-orientation-changes-in-android.html
首先,您需要将两个布局放在不同的文件夹中,例如 layout/test_layout.xml 和 layout-land/test_layout.xml
然后,您可以通过扩展 创建自定义布局您在test_layout.xml中使用的RelativeLayout或LinearLayout
然后,在自定义布局类中膨胀test_layout.xml,因此方向更改的问题将是 解决。
First you need to put two layouts in different folder like layout/test_layout.xml and layout-land/test_layout.xml
Then, You can create custom layout by extending RelativeLayout or LinearLayout which you used in test_layout.xml
Then, Inflate the test_layout.xml in custom layout class, so your problem of orienation change will be solve.