android - 如何更改特定 acitonbar 项目的颜色

标签 android android-layout android-actionbar

我正在尝试设计一个 Actionbar(Android 版本 >=2.3 使用支持 v7)。我希望特定按钮的颜色不同于其他按钮。

有什么简单的方法可以做到这一点吗?下面的示例设计

enter image description here

最佳答案

您可以从您的Activity Class

ActivityonCreate() 方法中,只需添加这些行并进行必要的导入即可。

        android.app.ActionBar bar = getActionBar();
        bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#d44334")));

它也适用于支持操作栏。

关于android - 如何更改特定 acitonbar 项目的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30247118/

相关文章:

android - 在精简版中显示 'full paid app' 功能?

安卓 : Create a button with border bottom

android - 将按钮的文本对齐到底部

android - Android ListView 的 transcriptMode 是什么?

android - 动态android字符串资源

java - 操作栏上的向上导航会关闭 Android 中的应用程序。无效输入连接

android - 使用 HoloEveryWhere 单击 ActionBar 上的 SearchView 图标时,如何隐藏子菜单?

Android O 预览版 : ConnectivityManager removed methods are not backward compatible

android - 如何刷新我的gridView?

android - 如何使用抽屉导航根据 fragment 更改菜单