1

I have work in a activity contains tabs. i need to set divider between two tabs

enter image description here i need a white horizontal divider line between all tabs

Here is my code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/social_bkg">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:layout_below="@+id/banner_layout">

    <TabHost
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

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

            <HorizontalScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:fillViewport="true"
                android:scrollbars="none">

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:divider="@drawable/tab_divider"
                    android:tabStripEnabled="false">

                </TabWidget>

            </HorizontalScrollView>

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


                <LinearLayout
                    android:id="@+id/tab1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@color/white"
                    android:orientation="vertical">

                    <WebView
                        android:id="@+id/business_tab_webView"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"/>

                </LinearLayout>
            </FrameLayout>
        </LinearLayout>
    </TabHost>

</LinearLayout>

Main Activity

In this main activity i have dynamically create tabs dynamic tabs are created no problem but dividers are not showing

eventTabHost = (TabHost) findViewById(android.R.id.tabhost);
eventTabHost.setup();
eventTabHost.getTabWidget().setShowDividers(TabWidget.SHOW_DIVIDER_MIDDLE);   eventTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);

tab_divider

by using this i create divider resourse file

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size android:width="1dp" />
<solid android:color="#ffffff" />
</shape> 
Sasi
  • 445
  • 4
  • 19
  • 1
    Possible duplicate of [How to set the divider between Tabs in TabLayout of design support library?](http://stackoverflow.com/questions/32204184/how-to-set-the-divider-between-tabs-in-tablayout-of-design-support-library) – Vygintas B Feb 03 '17 at 14:22
  • Try this: http://stackoverflow.com/a/32416751/5816000 This might solve your problem. – Bishu Feb 03 '17 at 14:22
  • how can i use it for widget – Sasi Feb 03 '17 at 14:55

0 Answers0