2012-06-30 42 views
0

我找到了一個教程,演示如何通過將android:background="@drawable/btn_green"添加到xml文件中來更改Buttonstyle如何使用android更改按鈕樣式:background =「@ drawable/btn_green」

我曾嘗試加入:

<Button 
    android:id="@+id/my_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="@string/hello" 
    android:background="@drawable/btn_green"/> 

我得到一個錯誤的xml文件說error: Error: No resource found that matches the given name (at 'background' with value '@drawable/btn_green').

教程說,我需要import the Backgrounds project into Eclipse by choosing the Import option from the File menu

我試過去File > Import但我找不到與背景有關的任何東西。

任何人都可以提出我需要做什麼?

+0

我想我在這裏感到困惑。我認爲有一種標準的背景風格庫可以添加到您的項目中。我認爲你必須製造你自己的? –

回答

0

檢查天氣名爲「btn_green」的形象出現在drawable- * dpi的文件夾

0

在繪製文件夾添加文件btn_green refesh項目和清潔&構建

0

你有這個Error: No resource found that matches the given name因爲沒有圖片的名稱btn_greendrawable文件夾中。

我想你想要圖像應該改變,當你點擊Button。爲此,您需要在xml文件中使用selector屬性。對於該讀取this post.