Search code examples
androidandroid-tabs

How to customize Sliding tab viewpager in android


I am developing an android application which uses sliding Viewpager of Tabs.(i.e).Sliding Tabs.
I have used the code from https://github.com/vgrec/SlidingMenuWithViewpager.
It works well. and now I want to customize tabs underline/tabs background color.
My Screenshot is shown below. enter image description here How could I do this?Thanks.


Solution

  • Try this:

    Replace the content of your left_menu.xml file with this

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/left_menu"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#CCC"
        android:orientation="vertical" xmlns:app="http://schemas.android.com/apk/res/org.grec">
    
        <com.astuetz.viewpager.extensions.PagerSlidingTabStrip
            android:id="@+id/tabs"
            app:shouldExpand="true"
            android:layout_width="match_parent"
            android:layout_alignParentBottom="true"
            android:layout_height="48dip"
            android:background="#00FF00"
    app:indicatorColor="#FF0000"
    app:underlineColor="#F6CECE" />
    
        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@id/tabs" />
    
    </RelativeLayout>  
    

    I have tested it see the snapshot:

    enter image description here