Nou*_*n H 1 java android styles colors button
我的应用程序中有几个按钮,我想将样式应用于所有这些按钮.
以下是我放在我的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>
Run Code Online (Sandbox Code Playgroud)
在我的布局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" />
Run Code Online (Sandbox Code Playgroud)
我收到以下错误"java.lang.NumberFormatException:颜色值'#282780'必须以#开头"
我检查了其他线程,但他们似乎都遇到这个问题,当他们使用@color,这不是我的情况.
先感谢您!
你给了以下风格的空间:
<item name="android:textColor"> #282780 </item>.删除后尝试.我不确定,但其他一切看起来都很好,这可能是问题所在.
| 归档时间: |
|
| 查看次数: |
1562 次 |
| 最近记录: |