2010-08-20 78 views
1

我在繪製文件夾中三幅圖像,和一個XML圖像按鈕代碼:Android - 圖像按鈕(XML)不起作用?

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android">\ 
<item android:state_pressed="true" 
android:drawable="@drawable/happycarrot" /> <!-- pressed --> 
<item android:state_focused="true" 
android:drawable="@drawable/largerunicornbutton2" /> <!-- focused --> 
<item android:drawable="@drawable/largerunicornbutton" /> <!-- default --> 
</selector> 

在我的佈局文件夾中,我有我的主要XML:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<ImageView 
android:src="@drawable/button" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent" 
></ImageView> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello" 
/> 
</LinearLayout> 

當我在emualtor運行我只得到第一張圖片。它什麼都不做。我能做些什麼來解決這個問題嗎?

回答

0

使用Linearlayout而不是相對的修復了問題。