Android:仅在一个选项卡上更改方向?
我使用带有三个选项卡小部件的选项卡主机,每个选项卡小部件托管一个视图。
我只希望其中一个选项卡对方向变化做出反应。
我尝试在 Activity 上注册 configChanges
并覆盖 onConfigurationChanged(..)
方法。然后,我使用显示测量来检测方向,并使用 setRequestedOrientation(..) 来更改它。
看起来 setRequestedOrientation(..) 只能工作一次,然后对它的所有其他调用都将被忽略。
有什么想法如何做到这一点?
注意:我不想为每个选项卡使用“活动” 1. 因为它浪费系统资源 2. 我已经尝试过但无法让它工作也可以使用该方法。
I'm using a tabhost with three tab widgets, each hosting a View.
I want only one of those tabs to react to an orientation change.
I've tried registering for configChanges
on the Activity and overriding the onConfigurationChanged(..)
method. I then detected orientation using Display measurements and used setRequestedOrientation(..)
to change it.
It seem setRequestedOrientation(..)
only works once, then all other calls to it are ignored.
Any ideas how to do this?
Note: I'd rather not use Activities for each tab 1. because it wastes system resources and 2. I've tried it already and couldn't get this to work on that method either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信这篇文章 可能对您的问题有几个充分的答案。其中之一涉及让侦听器更改每个选项卡单击的方向
另一个涉及使用 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
I believe this previous post may have several adequate answers to your question. One involves having a listener change the orientation on each tab click
and the other involves using
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);