[英]Attribute to change the color of the tab indicator
这个问题真的使我发疯。 我正在使用viewpager指示器,没有任何麻烦,但是我想更改最终结果:
我想将线条的颜色从蓝色更改为绿色; 显然,当选择一个选项卡时,我想保持相同的线条颜色。 这是我的样式文件:
<resources>
<style name="collection_field">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="collection_header" parent="collection_field">
<item name="android:textStyle">bold</item>
</style>
<style name="CollectionTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:textColor">@android:color/black</item>
</style>
<style name="Theme.Collection" parent="@android:style/Theme.Light.NoTitleBar">
<item name="vpiTabPageIndicatorStyle">@style/CollectionTabPageIndicator</item>
</style>
我应该使用什么属性来实现此目的? 多谢您的回覆。
您需要创建自己的标签指示器,然后使用CollectionTabPageIndicator
样式中的android:background
属性应用它们。
<style name="CollectionTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:textColor">@android:color/black</item>
<item name="android:background">@drawable/your_tab_indicator</item>
</style>
创建自己的绿色指示器的最简单方法是使用“ 动作栏样式生成器” 。
进入该页面后,打开“ Tab”发际线样式并应用“ Tab”指示器颜色 。 然后下载zip
,将所有选项卡指示器资源复制到适当的可绘制文件夹中,最后添加您的样式。
供参考,这是默认的蓝色指示器res / drawable / vpi__tab_indicator
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.