Android - 如何拥有混合方向的选项卡? (一些选项卡纵向,其他选项卡横向)
我创建了一个具有多个选项卡的应用程序,每个选项卡都有自己的布局。我已经关闭了对加速度计的响应,以使应用程序保持在纵向模式(android:screenOrientation="portrait")。
其中两个选项卡以纵向模式设计,一个选项卡以横向模式设计。我需要利用屏幕比横向高度更宽的事实来显示迷你电子表格。
这是我的问题:如何将其中一个选项卡定向为横向,同时将其他两个选项卡保持为纵向模式?
有什么建议吗?
I have created an app with multiple tabs, each with its own layout. I have shut down response to the accelerometer to keep the app in portrait mode (android:screenOrientation="portrait").
Two of the tabs are designed in portrait mode, and one tab is designed in landscape mode. I need to take advantage of the fact that the screen is wider than it is high in landscape to display a mini spreadsheet.
Here is my question: How do I orient one of the tabs to landscape, while leaving the other two in portrait mode?
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要以编程方式更改方向,请使用 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);或 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);。在这种情况下,每个选项卡单击事件都可以与其相关的方向源相关联
: http://russenreaktor.wordpress.com/2010/01/03/solved-set-screen-orientation-programmatically/
To programmatically change orientation use setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); or setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);. In this case each tab click event could be tied to its relevant orientation
source: http://russenreaktor.wordpress.com/2010/01/03/solved-set-screen-orientation-programmatically/
我在选项卡集之外找到了解决方案。以下链接讨论了显示垂直文本的多种解决方案:
垂直(旋转) Android 中的标签
我选择了 PocketMagic 的“CustomTextView”,可以在这里找到:http://www.pocketmagic.net/?p=1625
通过显示垂直文本的功能,我可以将整个选项卡集锁定在纵向模式下。
谢谢大家的建议。
-cc
I found a solution outside of the tab-set. The following link discusses multiple solutions for displaying Vertical text:
Vertical (rotated) label in Android
I went with "CustomTextView" by PocketMagic which can be found here: http://www.pocketmagic.net/?p=1625
With the ability to display vertical text, I can keep the entire tab-set locked in Portrait mode.
Thanks for the suggestions everyone.
-cc
不确定您是否得到答案,但我已经搜索了 30 分钟并找到了类似问题的解决方案。希望这有帮助。
我正在使用 tabhost,希望 4 个选项卡中的 3 个能够旋转,1 个选项卡仅设置为纵向模式。以前(应用此修复之前),3 个选项卡会旋转,直到选择固定的纵向选项卡,然后它们都卡在纵向模式下。
我必须设置其他选项卡以使用用户的方向来解决此问题。即在其他 3 个选项卡的 onResume 中添加了
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
,它现在完全按照我的预期工作。现在,3 个选项卡将根据用户的设备方向旋转,1 个选项卡固定为纵向。 :)not sure if you got an answer yet, but I've been searching for 30 mins and found a solution to a similar problem. Hope this helps.
I'm using tabhost and want 3 of 4 tabs to be able to rotate and 1 tab set to portrait mode only. Previously (before applying this fix) the 3 tabs would rotate until the fixed portrait tab was selected, then they were all stuck in portrait mode.
I had to set the other tabs to use the orientation of the USER to remedy this. i.e. added a
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
in the onResume of the other 3 tabs and it now works exactly as I had intended. 3 tabs will now rotate based on the user's orientation of the device, and 1 tab is fixed portrait. :)