TabWidget选项卡限制
我有一个 Android 应用程序,目前有 9 个选项卡。每当添加新选项卡时,所有选项卡的宽度都会调整得更小。我觉得添加另一个选项卡会使选项卡太小。有没有办法让 TabWidget 的侧面出现右/左箭头,类似于 .NET 选项卡控件,或者将 TabWidget 包装在 HorizontalScrollView 中会更好,如此处所述? 滚动选项卡小部件
I have an android application that currently has 9 tabs. Whenever a new tab is added, the widths of all the tabs are adjusted smaller. I feel that adding another tab will make the tabs too small. Is there a way to have a right/left arrow appear on the side of the TabWidget, similar to .NET tab controls, or would it be better to wrap a TabWidget in a HorizontalScrollView as described here? scrolling tabwidget
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
简单地将
TabWidget
放入HorizontalScrollView
中会遇到一个问题:TabWidget
中的View
不会填满屏幕并且具有不同的宽度。您可以通过设置其 minWidth 并将
HorizontalScrollView
的 android:fillViewport 设置为 true 来避免这种情况。因此,
您不需要为
TabSpec
指标制作自己的View
。Simply putting
TabWidget
in aHorizontalScrollView
will meet a problem:View
inTabWidget
will not fill the screen and have different width.You can avoid it by setting its minWidth and set the
HorizontalScrollView
's android:fillViewport as true.and
So you don't need to make your own
View
forTabSpec
indicators.您可以将
TabWidget
放入HorizontalScrollView
中,以便可以滚动选项卡。有关示例,请参阅这篇文章。
如果您需要在选项卡两侧放置按钮,您可以进一步包裹布局:
将
HorizontalScrollView
放入RelativeLayout
中,并将Buttons
放置在其左侧和右侧。在按钮的OnClickListener
中,您可以通过编程方式滚动TabWidget
。You can put your
TabWidget
into aHorizontalScrollView
, so you could scroll the tabs.For an example, please see this post.
If you need buttons on the two side of your tabs, you can wrap further the layout:
put the
HorizontalScrollView
inside aRelativeLayout
, and placeButtons
to the left and right side of it. In the buttons'OnClickListener
you can scroll theTabWidget
programatically.