2012-06-18 43 views
1

我的應用程序中有幾個按鈕,我想將樣式應用於所有樣式。樣式中定義的textColor未應用於按鈕文本

以下是我放入我的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這不是我的情況。

預先感謝您!

+0

您給出瞭如下樣式的空間:#282780。刪除後嘗試。我不知道,但其他一切都看起來很好,所以這可能是問題。 –

+0

你其實是對的!你能否單獨發佈你的答案,以便我可以標記它。太感謝了! –

回答

5

您給出瞭如下樣式的空間: <item name="android:textColor"> #282780 </item>。 刪除它後嘗試。我不知道,但其他一切都看起來很好,所以這可能是問題。

+0

介意.. + 1 ... –

相關問題