【问题标题】:Any easy way to change Android Action Bar "selected" color?有什么简单的方法可以更改 Android 操作栏“选定”颜色?
【发布时间】:2014-09-03 21:04:36
【问题描述】:

通过使用来自here 的Android 样式文档并查看源代码herehere,我能够更改很多颜色。

使用上面学到的知识,我能够更改 ActionBar.TabBar、ActionBar.TabText 和 ActionBar.TabView,但我不知道那个小亮点叫什么。从上面搜索 android 源代码中的全息蓝色也没有帮助。

我仍然不知道styles.xml中是否有任何方法可以指定要更改的“蓝色”突出显示颜色。


编辑:

我知道我可以使用操作栏样式生成器,但我正在研究是否可以在代码中设置它的颜色(无论是 java 还是 xml)。我不想为此目的生成一个新的drawable。

【问题讨论】:

标签: android android-tabhost android-theme android-tabs android-styles


【解决方案1】:

您可以使用的最简单的方法是使用Android Action Bar Style Generator 轻松地为您的操作栏和标签设置主题。

您也可以参考ActionBar Documents 自定义ActionBar。类似

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
    <item name="android:actionBarStyle">@style/MyActionBar</item>
    <!-- other activity and action bar styles here -->
</style>

<!-- style for the action bar backgrounds -->
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/ab_background</item>
    <item name="android:backgroundStacked">@drawable/ab_background</item>
    <item name="android:backgroundSplit">@drawable/ab_split_background</item>
</style>
</resources>

您也可以尝试ActionBarSherlock。库中有一个名为“Style ActionBar”的示例。使用它您可以更改ActionBar 选项卡下划线的颜色。

我还在对您问题的评论中看到了一个有用的链接。参考所有这些链接后,您就可以开始了。

希望这会有所帮助。

【讨论】:

  • 但是您将其更改为包含两种颜色的背景。实际的背景颜色和突出显示颜色...不是吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-16
  • 1970-01-01
  • 1970-01-01
  • 2023-03-09
  • 1970-01-01
相关资源
最近更新 更多