Search code examples
androidandroid-viewpagerandroid-tablayout

How to set padding for selection tab in TabLayout on Android


In my application I should TabLayout and ViewPager.
I want when selected Item set padding for tabIndicatorColor in tabLayout.

By default show me such as this image :
Image 1

Bu t I want when selected item, show me such as this :
enter image description here

I want set Padding for tabIndicatorColor.

My TabLayout XML code:

<android.support.design.widget.TabLayout
    android:id="@+id/serialDetail_tabLayout"
    android:layout_width="match_parent"
    android:layout_height="@dimen/size50"
    android:layout_gravity="bottom"
    android:background="@color/colorPrimary"
    app:tabIndicatorColor="@color/colorAccent"
    app:tabSelectedTextColor="@color/colorAccent"
    app:tabTextAppearance="@style/allCapsTabLayout"
    app:tabTextColor="@color/white" />

How can I it? please help me. Thanks all <3


Solution

  • There are two easy ways to do this. Either you use a custom layout for tab or just add a view below the tab of same color.The second option is more easier.