android - 如何更改标题栏的颜色

标签 android xml android-studio

我正在创建一个简单的 TicTacToe 游戏,首先我创建了一个启动画面。只需使用 activity_splash_screen.xml,我就可以轻松地将标题栏颜色更改为橙​​色。

enter image description here

然后我创建了名为 activity_home.xml 的主页。当我点击那里的栏时,它不会激活,因此不允许我将颜色从蓝色更改为橙​​色。您能否向我解释一下如何解决这个问题

enter image description here

提前致谢。

最佳答案

在 AppTheme 的 styles.xml 中,android:colorPrimary 属性负责将工具栏颜色更改为您的颜色。

 <style name="AppTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!--   your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!--   darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!--   theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>

或将以下属性应用到您的工具栏

android:background="@color/colorPrimary" 

关于android - 如何更改标题栏的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48001757/

相关文章:

android - 向 Android Share-Sheet 添加自定义操作

android - Fabric、Crashylitics 堆栈跟踪未进行反混淆。安卓

android - react native 异常 java.lang.UnsatisfiedLinkError : dlopen failed: "/data/data/{package}/lib-main/libgnuSTL_shared.so" is 32-bit instead of 64-bit

java - 无法恢复 Activity

c# - 在 C# 中实现 DSL 以生成特定于域的 XML

android - android :uses-permission and uses-permission?有什么区别

android - 我的 Android Studio 上缺少调试窗口

android - Android Studio ndk-build使用非零值2完成

Android:来自 xml 布局的自定义 View

android - 如何从 firebase 数据库中检索包含子名称的字符串列表?