设置选定的 TAB,其下方有一个小三角形
我希望我的选项卡显示如下图所示,下方带有小三角形。这可能吗?如果是,请帮助我提供一些代码或文档。
I want my tabs to show like in the image with small triangle below it.Is this possible ?If yes, then help me with some codes or documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为,以下方法是最简单的方法。您只需要设置以下可绘制对象(实际上,这是 Android 选项卡的默认可绘制对象)作为选项卡的背景:
其中
tab_press
、tab_focus
和tab_selecteddrawables 将是 png 的(我更喜欢 9 个补丁),其附近有向下箭头和透明区域。
tab_unselected
可绘制对象不会有此箭头,但仍具有相同的透明区域。剩下要做的唯一一件事就是为TabWidget
指定负下边距。它的值由箭头的高度决定(不要忘记使用 密度独立单位):I think, the following approach is the simplest one. You just need to setup the following drawable (actually, it's Android's default drawable for tabs) as a background of the tabs:
where
tab_press
,tab_focus
andtab_selected
drawables would be png's (I'd prefer 9-patches) with down-arrow and transparent region near it.tab_unselected
drawable wouldn't have this arrow, but still would have same transparent region. The only thing left to do is to specify negative bottom margin for yourTabWidget
. Its value is determined by the height of the arrow (do not forget to use density independent units):tab_0_info.xml:
tab_0_info.xml:
您可以使用选项卡将图像添加到布局:
并在选项卡活动中添加侦听器:
You can add images to layout with tabs:
and add listener in your tab activity: