Android:可滚动选项卡
我目前正在开发我的第一个 Android 应用程序。我正在为我的应用程序使用选项卡式布局。我按照开发指南上的教程进行操作,但遇到了问题。本教程只使用了三个选项卡,但我需要更多。因此,选项卡会调整大小并聚集在一起。我希望有人能告诉我如何让它们滚动,就像在海豚浏览器中使用多个选项卡时一样。谢谢!
〜亚伦
I'm currently working on my first android application. I am using a tabbed layout for my application. I followed the tutorial for this on the dev guide and ran into a problem. The tutorial only used three tabs, but I have a need for more. As such, the tabs resize and bunch up. I was hoping someone could tell me how I can make them scroll, like in dolphin browser when using multiple tabs. Thanks!
~aaron
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 Yoel 所说的,只需添加:
android:fillViewport="true
和android:scrollbars="none"
到 HorizontalScrollView 如下:
Using what Yoel said, just add:
android:fillViewport="true
andandroid:scrollbars="none"
to HorizontalScrollView like this:
我建议用 HotizontalScrollView 来包装 TabWidget。这样您仍然可以按原样使用选项卡。
需要注意的是,如果您使用较少的选项卡,这将导致选项卡无法填充屏幕的整个宽度。我目前正在寻找这个问题的解决方案。
I would recommend to wrap the TabWidget with HotizontalScrollView instead. this way you can still use the tabs as they are.
It is important to note that if you are using less tabs, this will cause the tab's not to fill the whole width of the screen. I am currently looking for a solution for this issue.
在这种情况下,您可能不想使用选项卡。相反,您可以将所有“选项卡”放入屏幕顶部的水平线性布局中,包裹在 ScrollView 中,如下所示
我认为这将为您提供您正在寻找的结果,但请告诉我
in this case you probably dont want to use tabs. Rather, you can put all of your "tabs" in to a horizontal linear layout at the top of the screen wrapped in a ScrollView like this
I think that this will give you the result you are looking for, but let me know