Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何更改工具栏颜色大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在搜索如何自定义工具栏,例如如何添加背景颜色,但我不明白它是如何工作的.

我一直在尝试为我的工具栏添加自定义样式,但任何结果……

清单

<application
        android:allowBACkup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@String/app_name"
        android:theme="@style/Theme.Design">

style.xml文件

<resources>

    <style name="Theme.Design" parent="Base.Theme.Design">
    </style>

    <style name="Base.Theme.Design" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPriMary">@color/red</item>
        <item name="colorPriMaryDark">@color/red</item>
        <item name="colOraccent">@color/red</item>
        <item name="android:textColorPriMary">@color/white</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="windowActionBarOverlay">true</item>
    </style>    
    ...

和布局中的工具栏

<android.support.v7.widget.Toolbar
            android:id="@+id/home_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"/>

解决方法

谢谢,但任何解决方案都有效.
<android.support.v7.widget.Toolbar
            android:id="@+id/home_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:BACkground="?attr/colorPriMary"/>

要么

toolbar.setBACkgroundColor(Color.parseColor("#80000000"));

可能是因为我的工具栏在Android.support.design.widget.CoordinatorLayout(放一个android.support.design.widget.FloaTingActionButton)?

大佬总结

以上是大佬教程为你收集整理的android – 如何更改工具栏颜色全部内容,希望文章能够帮你解决android – 如何更改工具栏颜色所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。