Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Color TabSelector on v4 ViewPager

Is it possible to change color of selected tab on v4 ViewPager?
I need to use v4 ViewPager, but I don't find any source to customize it.
Just to clarify I need to change the blue color to another one:

TabSelector

like image 445
Tizianoreica Avatar asked Aug 06 '13 10:08

Tizianoreica


People also ask

How do I change the tab color on my Android?

You can simply change the background of the whole TabLayout using the app:tabBackground property and you can change the tab indicator color using the app:tabIndicatorColor property, but there are better ways if you want more functionality.

How do I change the color of my tab text?

Right-click the worksheet tab whose color you want to change. Choose Tab Color, and then select the color you want. The color of the tab changes, but not the color of the font. When you choose a dark tab color, the font switches to white, and when you choose a light color for the tab, the font switches to black.


2 Answers

This is the tab indicator. You can change its color by applying different styles.

Use Action Bar Style Generator, generate 9patch png files (tab_selected, tab_selected_focused etc.) and add these files + styles to your project.

Another approach -> How to change the current tab highlighter color in Android ViewPager? (as @Pratik wrote in comment).

like image 102
mmBs Avatar answered Oct 05 '22 17:10

mmBs


I don't have enough reputation to comment on an Answer, but regarding the Action Bar Style Generator make sure after you add the files to the corresponding folders in your project that you also add the theme to your manifest xml file like this:

<activity
    android:name="com.whatever.myapplication.YourActivityName"
    android:theme="@style/Theme.Whatever_you_named_your_style_in_the_generator">
</activity>
like image 35
esme_louise Avatar answered Oct 05 '22 17:10

esme_louise