gpt4 book ai didi

android - 在android中更改我的ActionBar的背景颜色

转载 作者:行者123 更新时间:2023-11-30 02:26:04 25 4
gpt4 key购买 nike

美好的一天!

首先,我已经在网上查过这个问题并应用了建议的解决方案。但是,它仍然没有改变溢出的 bg 颜色。我检查的最后一个线程是 this

答案非常有用,尤其是 Jonik 的答案。但是,我仍然无法更改操作栏上溢出的颜色。这是我的主题的代码:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle" tools:ignore="NewApi">@style/Actionbar</item>
<item name="actionBarStyle">@style/Actionbar</item>
<item name="drawerArrowStyle">@style/ArrowStyle</item>
<item name="android:popupMenuStyle">@style/PopupBackground</item>
</style>

<style name="Actionbar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background" tools:ignore="NewApi">@color/primary</item>
<item name="background">@color/primary</item>
</style>

<style name="grrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="android:color">@color/white</item>
</style>
<!-- Customize your overflow here. -->
<style name="PopupBackground" parent="Widget.AppCompat.ListPopupWindow">
<item name="android:popupBackground">@color/primary</item>
</style>

原色设置为深蓝色。执行代码后,溢出仍然显示黑色背景而不是深蓝色,只有操作栏设置为深蓝色。

有什么地方我做错了或没有注意到吗?我已经编辑了一段时间了,我已经实现了我在堆栈和其他教程中找到的大部分建议解决方案。但是,我仍然无法更改它。非常感谢任何帮助或链接。

最佳答案

Try this by code programatically

ActionBar ab = getActionBar();
ab.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0000ff")));

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

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