gpt4 book ai didi

java - 样式中定义的 textColor 未应用于按钮文本

转载 作者:行者123 更新时间:2023-11-29 08:06:10 27 4
gpt4 key购买 nike

我的应用程序中有几个按钮,我想为所有按钮应用一种样式。

以下是我放在 values 文件夹中的 styles.xml 文件。

<?xml version="1.0" encoding="utf-8"?>

<resources>

<style name="buttonStyle">
<item name="android:textStyle"> bold </item>
<item name="android:textColor"> #282780 </item>
<item name="android:textSize"> 20sp </item>
</style>

</resources>

在我的布局 xml 文件中,我使用按钮内的样式如下,

<Button android:id="@+id/ok_preview_appointment_button" 
android:text="@string/ok_preview_appointment_button"
android:layout_width="175dp"
android:layout_height="35dp"
android:layout_marginBottom="10dp"
style="@style/buttonStyle"
android:background="@drawable/button_background" />

我收到以下错误“java.lang.NumberFormatException:颜色值‘#282780’必须以#开头”

我检查了其他线程,但他们似乎都在使用 @color 时遇到了这个问题,这不是我的情况。

提前致谢!

最佳答案

你在风格上给了空间,比如: <item name="android:textColor"> #282780 </item> .去掉后试试。我不确定,但其他一切看起来都很好,所以这可能是问题所在。

关于java - 样式中定义的 textColor 未应用于按钮文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11083064/

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