TabWidgets 之间的分隔线 [英] dividers between TabWidgets

查看:28
本文介绍了TabWidgets 之间的分隔线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TabWidget 下的 android:divider 属性是否有效?我尝试了来自 android 的 Tab Layout 教程只是为了测试(http://developer.android.com/resources/tutorials/views/hello-tabwidget.html)并将 android:divider 设置为某个图像(现在我使用 android 垂直滚动条作为可绘制对象,以真正强调它是否被选中向上(从框架复制它),但是当我在模拟器上运行它时,它似乎没有工作.根据文档,TabWidget 似乎确实支持这个属性:可绘制用于在选项卡之间绘制分隔线."

Is the android:divider attribute under the TabWidget working? I tried the Tab Layout tutorial from android just to test (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html) and set the android:divider to some image (for now I used the android vertical scrollbar as the drawable to really emphasize if its getting picked up (copied it from frameworks), but when I ran it on the emulator, it doesn't appear to be working. According to the docs, the TabWidget does seem to support this attribute: "Drawable used to draw the divider between tabs."

有人可以帮忙吗?我正在使用九个补丁的可绘制对象作为我的分隔图像可绘制对象.

Can anyone help? I am using a nine-patched drawable as my divider image drawable.

MB

推荐答案

divider 属性似乎不再适用于 TabWidget.添加自定义分隔符的一种方法是以编程方式设置它:

It doesn't look like the divider attribute is available anymore for TabWidget. One way to add a custom divider is to set it programmatically:

mTabHost.getTabWidget().setDividerDrawable(R.drawable.divider_vertical_dark);

但是,请确保在设置选项卡的内容之前调用它.如果我之后调用它,它会崩溃.

Make sure however, you call this before you set the content of the tabs. It would crash on me if I called it after.

这篇关于TabWidgets 之间的分隔线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆