Change background color of tabBar in v4 viewPager

538 views Asked by At

I'm building an app for Android using a viewPager, and things work just fine on a phone, but on a tablet there is a gray background on both sides of the tabs, the need is to change this background color to white.

On a phone it Looks just fine, sorry for ugly censoring

On a tablet the gray background appears

<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:background="@color/white" />

The styles I've tried to override are the ones below, I've tried to set most properties that contain the word "color" to white, but nothing has worked.

  • android:actionBarStyle
  • android:actionBarTabStyle
  • android:actionBarTabBarStyle

I base my theme on Theme.AppCompat.Light

I've also tried setting the background of the viewPager and actionBar in code, but it did nothing, I'm guessing it's a subview I need to get to. I've been googling my heart out but I can't find anything about this specific styling.

1

There are 1 answers

1
Shoeb Siddique On

You can do something like this.

  <?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"
         tools:context=".MainActivity"
        android:background="@android:color/white" >


            <android.support.v4.view.ViewPager
                android:id="@+id/pager"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@android:color/white"  />

    </RelativeLayout>