gpt4 book ai didi

android - 为什么我的按钮将 "colorPrimary"作为默认背景颜色?

转载 作者:行者123 更新时间:2023-12-04 23:53:07 24 4
gpt4 key购买 nike

 <Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="Explore"
android:id="@+id/btn_dialog"
android:gravity="center_vertical|center_horizontal"
android:layout_below="@+id/text_dialog"
android:layout_marginBottom="20dp"
android:layout_centerHorizontal="true"
android:textColor="#ffffff" />

这是我的 colors.xml 文件。

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#00ccff</color>
<color name="colorPrimaryDark">#00ccff</color>
<color name="colorAccent">#00ccff</color>
<color name="darkPrimary">#212121</color>
<color name="darkPrimaryDark">#000000</color>
<color name="whitecolor">#FFFFFF</color>
<color name="switchcolor">#f0f0f0</color>
</resources>

样式文件如下:

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>

当我尝试像这样设置背景颜色时: android:background="#f0f0f0" ,背景颜色没有变化。我正在尝试修复大约一个小时左右。请提供任何帮助。

最佳答案

在您的布局 XML 中使用 app:backgroundTint。它将改变应用程序的原色背景的颜色

关于android - 为什么我的按钮将 "colorPrimary"作为默认背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61188079/

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