我正在尝试使用JakeWharton
/ Android-ViewPagerIndicator
在标签中添加新项目的指示符(小徽章显示有新内容)。
我从库中扩展了PageIndicator
并创建了自定义CustomPageIndicator
。我从TabPageIndicator
复制的大部分内容。我刚刚更改了addTab方法返回的View。此视图从xml中膨胀。
当我运行我的应用程序时,从CustomPageIndicator
创建的指标没有任何样式集。应用程序中的所有其他指标都很好。
我尝试将样式和背景设置为ViewPagerIndicator
和自定义xml布局的根视图。结果非常糟糕。我有一些着色但突出显示不起作用等。
代码:
它看起来如何:
那么我需要添加哪些才能在我的自定义指标上添加样式?
答案 0 :(得分:2)
好的,我在github的帮助下使用了这个主题。 https://github.com/JakeWharton/Android-ViewPagerIndicator/issues/94
我所做的改变:
- 为CustomTabView添加了一个不同的超级调用(这是我用XML格式化的视图)
super(context, null,com.viewpagerindicator.R.attr.vpiTabPageIndicatorStyle);
- 在CustomPageIndicator(Context context,AttributeSet attrs)构造函数中更改超级调用
super(new ContextThemeWrapper(context,R.style.Theme_VPI), attrs);
R.style.Theme_VPI是我的style.xml中定义的自定义主题
<style name="Theme.VPI" parent="Theme.abstyle">
<item name="vpiTabPageIndicatorStyle">@style/CustomTabPageIndicator</item>
</style>