roiberg
roiberg

Reputation: 13747

Remove space between tabs in android.

I am doing a tab layout. My problem is that there is a small space between my tabs. enter image description here

thats my xml:

<TabHost
    android:id="@+id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.8" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:dividerPadding="0dp"
            android:fitsSystemWindows="true"
            android:gravity="fill"
            android:orientation="horizontal"
            android:showDividers="none"
            android:visibility="visible" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:id="@+id/left_tab"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:showDividers="none" >

thats my java code:

public void CreateTabs(ImageView leftI, ImageView rightI, ImageView middleI, TabHost tabH) {
    leftI.setImageDrawable(getResources().getDrawable(R.drawable.btn_tab_news));
    leftI.setScaleType(ScaleType.FIT_XY);
    rightI.setImageDrawable(getResources()
            .getDrawable(R.drawable.btn_tab_calender));
    rightI.setScaleType(ScaleType.FIT_XY);
    middleI.setImageDrawable(getResources()
            .getDrawable(R.drawable.btn_tab_press));
    middleI.setScaleType(ScaleType.FIT_XY);
    tabH.setup();
    TabSpec specs = tabH.newTabSpec("tag1");
    specs.setContent(R.id.right_tab);
    specs.setIndicator(rightI);
    tabH.addTab(specs);
    specs = tabH.newTabSpec("tag2");
    specs.setContent(R.id.middle_tab);
    specs.setIndicator(middleI);
    tabH.addTab(specs);
    specs = tabH.newTabSpec("tag3");
    specs.setContent(R.id.left_tab);
    specs.setIndicator(leftI);
    tabH.addTab(specs);
}

Why is it happening and how can I fix this? Thanks!

Upvotes: 1

Views: 4529

Answers (1)

awsleiman
awsleiman

Reputation: 1909

you need to add this:

<android.support.design.widget.TabLayout
    app:tabPaddingStart="0dp"
    app:tabPaddingEnd="0dp" />

Upvotes: 8

Related Questions