Skip to content Skip to sidebar Skip to footer

How To Change Color Of The Tabstrip In Android?

I am trying to change the color of my tabStrip to white, the code below is not working? What am I doing wrong ? getTabHost().getTabWidget().setLeftStripDrawable(Color.WHITE); getTa

Solution 1:

Use any drawable instead of color

means setLeftStripDrawable is requiring a drawable resource but you are giving int as a argument.

So either use a drawable image here. Or use a xml from drawable contaning the color.

Solution 2:

i hope you want to change the color of the background of the tab strip. You could achieve this by creating a layout with a root element as

tab_strip.xml

<?xml version="1.0" encoding="utf-8"?><android.support.design.widget.TabLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#FFFFFF"></android.support.design.widget.TabLayout>

and in your xml where you are using tab, you could add the tab_strip.xml as follows

<include android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/toolbar"
        layout="@layout/tab_strip"/>

And this will make your tab strip colour to white.

Solution 3:

You can change the color with app:tabIndicatorColor="@color/indicator_color inside the Tablayout.

<android.support.design.widget.TabLayout
    app:tabIndicatorColor="@color/indicator_color
        />

Post a Comment for "How To Change Color Of The Tabstrip In Android?"