我想删除tabwidgets之间的间距。默认情况下,选项卡之间的间距约为1px。我知道像foursquare或posterous这样的应用程序能够删除它。这样做的代码怎么样?我使用的是2.3 API。
感谢您的帮助
答案 0 :(得分:6)
你可以使用getTabHost()。getTabWidget()。setDividerDrawable(R.drawable.empty_divider)方法, 其中R.drawable.empty_divider简单形状,大小为0px,例如
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<size
android:width="0px"
android:color="@android:color/black"
android:dashWidth="0px"
android:dashGap="0px" />
</shape>
答案 1 :(得分:5)
TabWidget android:showDividers =&#34; none&#34;
答案 2 :(得分:4)
如果您的构建目标是Honeycomb以后,您可以使用以下代码。
if (Integer.parseInt(Build.VERSION.SDK) >= Build.VERSION_CODES.HONEYCOMB) {
tabHost.getTabWidget().setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
}
答案 3 :(得分:3)
我用这行代码解决了同样的问题:
tabHost.getTabWidget().setDividerDrawable(null);
答案 4 :(得分:2)
你可以添加android:showDividers =&#34; none&#34;到布局XML
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:showDividers="none" />