gpt4 book ai didi

android - 如何更改android中标签栏的突出显示颜色

转载 作者:行者123 更新时间:2023-11-29 17:44:04 24 4
gpt4 key购买 nike

我想改变标签栏的高亮颜色。我还将使用 Android Action Bar Style Generator 来更改颜色,但它不会改变。

样式.xml

<resources>

<style name="Theme.Example" parent="@android:style/Theme.Holo">

<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Example</item>

</style>

<style name="ActionBarTabStyle.Example" parent="@android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_example</item>
</style>

</resources>

tab_indicator_ab_example

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@android:color/transparent" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_example" />

<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_example" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_example" />

<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_example" />

<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_example" />
</selector>

请指导我更改标签栏的突出显示颜色

最佳答案

我已将此代码添加到我的应用程序中。现在您可以轻松地将此代码放入您的应用程序,我希望这对您来说很好。

请将下面的文件放入您的可绘制文件夹中,并将此文件设置为您的背景。

tab_bg_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/tab_selected" android:state_pressed="true"/>
<item android:drawable="@color/tab_selected" android:state_selected="true"/>
<item android:drawable="@color/tab_normal"/>

</selector>

将此代码放入您的 res -> values -> color.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name = "tab_normal"> #FF0000 </color>
<color name = "tab_selected"> #000000 </color>
</resources>

关于android - 如何更改android中标签栏的突出显示颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27636344/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com