pzagor2
pzagor2

Reputation: 719

Custom PageIndicator from ViewPagerIndicator has no style

I’m trying to put an indicator of new items (small badge showing that there is new content) in tabs, using JakeWharton / Android-ViewPagerIndicator.

I extended PageIndicator from library and created my custom CustomPageIndicator. Most of the things I copied from TabPageIndicator. I just changed the View that is returned in addTab method. This view is inflated from xml.

When I run my application the indicator created from CustomPageIndicator does not have any style set. All other indicator in app are just fine.

I tried to set style and background to both ViewPagerIndicator and root view of my custom xml layout. The results were pretty bad. I got some coloring but highlighting didn't work etc.

Code for:

How it looks like:

enter image description here

So what would i have to add to get the styling on my custom indicator?

Upvotes: 0

Views: 3644

Answers (1)

pzagor2
pzagor2

Reputation: 719

Ok i got it to work with the help of this topic on github. https://github.com/JakeWharton/Android-ViewPagerIndicator/issues/94

Changes i made:

-Added a different super call to CustomTabView (this is view that i inflate form XML)

super(context, null,com.viewpagerindicator.R.attr.vpiTabPageIndicatorStyle);

-Changed the super call in CustomPageIndicator(Context context, AttributeSet attrs) constructor to

super(new ContextThemeWrapper(context,R.style.Theme_VPI), attrs);

R.style.Theme_VPI is a custom theme defined in my style.xml

<style name="Theme.VPI" parent="Theme.abstyle">
    <item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicator</item>
</style>

Upvotes: 2

Related Questions