android – 如何更改工具栏颜色

android – 如何更改工具栏颜色,第1张

概述我一直在搜索如何自定义工具栏,例如如何添加背景颜色,但我不明白它是如何工作的. 我一直在尝试为我的工具栏添加自定义样式,但任何结果…… 清单 <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_nam 我一直在搜索如何自定义工具栏,例如如何添加背景颜色,但我不明白它是如何工作的.

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

清单

<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 – 如何更改工具栏颜色所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1134845.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存