天天看點

android tag屬性,android – tag需要’drawable’屬性

我試圖非常簡單地設計一個Button.我隻是希望它在沒有按下時帶有文本藍色,而在單擊時帶有藍色文本.

我嘗試用樣式和選擇器來做到這一點.

在我的布局中我有這個按鈕:

android:id="@+id/button1"

style="@style/MyButton"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="1"

android:text="@string/login" />

在res / values / styles中我有這個styles.xml:

@drawable/btn_background

@drawable/btn_textcolor

當然,兩個選擇器,在res / drawable中,btn_background.xml:

和btn_textcolor.xml:

我運作應用程式或打開布局編輯器時出現的錯誤是:

tag requires a ‘drawable’ attribute

我了解這個消息,但我沒有一個可繪制的,它是一個簡單的扁平按鈕.

我怎樣才能建立這麼簡單的按鈕?

根據 this post

更新,它應該工作.