Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PagerTabStrip title background color

I changed the background color in PagerTabStrip, but the tabs titles have a white background

<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >

<android.support.v4.view.PagerTabStrip
    android:id="@+id/pager_tab_strip"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="#c9c9c9"
    android:padding="4dp"
    android:textColor="#000000"
    />

where do I change it?

like image 613
Amir.F Avatar asked Nov 27 '22 09:11

Amir.F


2 Answers

Create a resource file if it does not exist (for colors) at res/values/colors.xml with a color having the value you want.

<?xml version="1.0" encoding="utf-8"?>

<resources>
    <color name="tabstrip_bg">#ff6d9850</color>
</resources>

In your layout file (holding respective ViewPager and TabStrip) modify the android:background parameter that refers to above color, as shown below.

<android.support.v4.view.ViewPager
    android:id="@+id/pager_charts"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <android.support.v4.view.PagerTabStrip
        android:id="@+id/pager_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:background="@color/tabstrip_bg" />
</android.support.v4.view.ViewPager>
like image 120
retromuz Avatar answered Nov 28 '22 22:11

retromuz


Try inserting this XML code:

android:textColor="#<COLOR-CODE>"

like image 31
The Badak Avatar answered Nov 28 '22 21:11

The Badak