gpt4 book ai didi

android - 如何在操作栏选项卡中以编程方式更改选定的选项卡指示器颜色

转载 作者:行者123 更新时间:2023-11-30 02:40:08 27 4
gpt4 key购买 nike

我有 ListView ,每个列表项都有不同的颜色。单击任何列表项,我导航到一个 Activity ,其操作栏包含一些选项卡。现在我必须将来自项目点击的颜色设置为所选选项卡的选项卡指示器颜色。我尝试了以下链接,但没有成功

Is it possible to change actionbar tab indicator programmatically

最佳答案

您可以更改所选标签的焦点

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

<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
android:state_pressed="false"
android:drawable="@drawable/tab_unselected_focused" />
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/tab_selected_focused" />
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false"
android:state_pressed="true"
android:drawable="@drawable/tab_unselected_pressed" />
<item android:state_focused="false" android:state_selected="true"
android:state_pressed="true"
android:drawable="@drawable/tab_selected_pressed" />

<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_focused="true" android:state_selected="false"
android:state_pressed="true"
android:drawable="@drawable/tab_unselected_pressed" />
<item android:state_focused="true" android:state_selected="true"
android:state_pressed="true"
android:drawable="@drawable/tab_selected_pressed" />

有关更多详细信息,请访问 this

关于android - 如何在操作栏选项卡中以编程方式更改选定的选项卡指示器颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25904916/

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