[英]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.