我想在用戶點擊一個按鈕時使用2張圖片來產生效果。 我認爲我做得很好,但效果不起作用。Android按鈕效果不起作用
具體來說,按鈕背景設置爲camera_button_after.jpg,它的意思是按下狀態,點擊時不會改變。
你能告訴我什麼是錯?我會非常感激。
這裏是包含按鈕的main_frame.xml。
main_btn1.xml,main_btn2.xml,main_btn3.xml是選擇器。 這三個選擇具有相同的結構,也同樣的問題..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/button001"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/main_btn1"
android:text=" Mood"
android:textSize="30dp"/>
<Button
android:id="@+id/button002"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/main_btn2"
android:text=" Mood Lists"
android:textSize="30dp"/>
<Button
android:id="@+id/button003"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/main_btn3"
android:text=" Help"
android:textSize="30dp" />
</LinearLayout>
這裏是main_btn1.xml
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="false"
android:drawable="@drawable/camera_button_before" />
<item
android:state_pressed="true"
android:drawable="@drawable/camera_button_after"/>
</selector>
一個問題is..I認爲Eclipse不充分認識到圖片和xml文件。我打掃項目幾次,然後重新啓動Eclipse的,但他們仍然有問號像下面
它沒有爲我工作。我認爲這是日食問題。我在最後一個問題的下面提出了一些額外的問題,你可以看看,並告訴我如何擺脫那個問號? – user3473222 2015-02-11 13:28:05