2011-02-15 97 views
1

我跟着this tutorial爲Android做了一些更好的按鈕,我也從該網站上拿了9-patch按鈕的例子。它是這一個:enter image description here9-補丁按鈕顯示不正確

但正如你在下面的圖片中看到的,我的按鈕顯示不正確。

enter image description here

這裏是 「4×4」 按鈕的代碼:

<Button android:id="@+id/btn4" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:onClick="starteSpiel" 
     android:text=" 4 x 4 " 
     android:background="@drawable/button" /> 

這裏是我的button.xml:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:state_focused="true" 
    android:state_pressed="false" 
    android:drawable="@drawable/button_normal" /> 
<item android:state_focused="true" 
     android:state_pressed="true" 
     android:drawable="@drawable/button_normal" /> 
<item android:state_focused="false" 
     android:state_pressed="true" 
    android:drawable="@drawable/button_normal" /> 
<item android:drawable="@drawable/button_normal" /> 

在哪裏錯誤?按鈕應該看起來像tutorial中的那些按鈕。

+2

您可能需要將其保存爲wtiVz.9.png文件擴展名。 – Jems 2011-02-15 14:35:14

+0

是的,就是這樣。謝謝! – Maaalte 2011-02-15 14:44:27

回答

3

嘗試通過直接設置在Button/@android:brackground

@drawable/button_normal簡化代碼通過閱讀你的代碼,我明白你(在教程文件名)改名爲button.9.pngbutton_normal.9.png - 是嗎?