屏幕方向

发布于 2024-10-14 10:39:01 字数 180 浏览 6 评论 0原文

你好 我是android新手。我遇到了一个问题,即在横向模式下,我需要一个布局视图,它没有纵向模式中存在的一些字段。我已经以这种方式创建了横向视图的布局。在我给出的活动中像纵向显示某些字段这样的条件会隐藏一些。它实际上工作正常...首先,当我从纵向转到横向时,它给出了我想要的...但是当我进入纵向模式时,它停止了应用程序。请帮助我。提前致谢

Hi
M new to android.I faced a problem i.e in landscape mode i need a layout view which doesnot have some feilds which are present in the portrait mode.I have created a layout for landscape view in such a way.In the activity i have given the conditions like if portrait display some feilds some hide.its working properly actually...first when i go from portrait to landscape it is giving what i want...but when i go to portrait mode its stopping the application.please help me.Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

救星 2024-10-21 10:39:01

你可以制作两种不同的布局,分别放在layout-port和layout-land中。
并确保您在该活动的清单中提到了 android:configuration = "orientation"。如果我正确理解了你的话,请尝试一下。

You can make two different layouts and put them in layout-port and layout-land respectively.
And make sure that you have mentioned android:configuration = "orientation" in your manifest for that activity. Try it if i have understood you correctly.

無處可尋 2024-10-21 10:39:01

我认为坎特什的建议可能是倒退的。如文档中所述,如果您包含 android:configChanges=如果清单中包含“orientation”,则不会自动加载正确的资源(来自布局端口或布局土地)。相反,不要在清单中提及方向。然后,您无需担心 onConfigurationChanged() (不要覆盖它)。系统将自动关闭该活动,然后重新启动它,绑定相应版本的配置相关资源。自己处理配置更改(同样,根据文档)只是处理无法通过其他方式处理的性能问题的最后手段。

I think that the advice by Kantesh may be backwards. As explained in the docs, if you include android:configChanges="orientation" in the manifest, then the correct resource (from layout-port or layout-land) won't be automatically loaded. Instead, leave out mention of orientation from the manifest. Then, you do not need to worry about onConfigurationChanged() (don't override it). The system will automatically shut down the activity and then restart it, binding the appropriate version of configuration-dependent resources. Handling configuration changes yourself is (again, according to the docs) only a last resort to deal with performance issues that cannot be handled in other ways.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文