gpt4 book ai didi

android - 更改 Sherlock TabBar 背景颜色

转载 作者:行者123 更新时间:2023-11-29 20:53:46 24 4
gpt4 key购买 nike

我正在尝试自定义 SherlockTabBar,但在更改选项卡背景颜色时卡住了。我已经使用了“ActionBarStyle Generator”并从那里复制了我有兴趣更改的资源。现在我设法更改了选定的选项卡指示器,但我不知道如何更改选项卡背景以及选项卡指示器。我的自定义样式代码如下所示:

  <style name="Theme.Custom" parent="style/Theme.Sherlock.Light">
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
</style>

<style name="MyActionBarTabStyle" parent="style/Widget.Sherlock.Light.ActionBar">
<item name="android:background">@drawable/actionbarselector</item>
<item name="android:gravity">center</item>
</style>

和选择器:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_customstyle"/>
<item android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_customstyle" />
<item android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_customstyle" />
</selector>

有什么建议吗?

最佳答案

感谢@Hemant 的领导,但您发布的代码将更改操作栏背景颜色而不是选项卡栏。但是查看该代码,我想到以编程方式而不是按样式设置它,如下所示:

SupportActionBar.SetStackedBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.ab_stacked_solid_customstyle));

再次感谢。

关于android - 更改 Sherlock TabBar 背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28339747/

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