问题
I would like to remove the spacing between tabwidgets. By default there is around 1px spacings between tabs. I know some apps like foursquare or posterous are able to remove it. How is the code to do this would look like? I am using 2.3 API.
Thank you for your help
回答1:
You can use getTabHost().getTabWidget().setDividerDrawable(R.drawable.empty_divider) method, where R.drawable.empty_divider simple shape with 0px size, such as
<?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>
回答2:
TabWidget android:showDividers="none"
回答3:
If your build target is Honeycomb onwards, you may use the following code.
if (Integer.parseInt(Build.VERSION.SDK) >= Build.VERSION_CODES.HONEYCOMB) {
tabHost.getTabWidget().setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
}
回答4:
I solve this same problem with this line of code:
tabHost.getTabWidget().setDividerDrawable(null);
回答5:
You can add android:showDividers="none" to Layout XML
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:showDividers="none" />
来源:https://stackoverflow.com/questions/5805223/how-can-i-remove-the-space-between-tab-widget