How can I remove the space between tab widget?

蹲街弑〆低调 提交于 2020-01-10 04:22:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!