2010-07-23 21 views
1

看,左邊的按鍵是Android 2.1系統,在右邊的是2.2:android 2.1 xml drawables中的錯誤?在下面的圖像

alt text http://www.freeimagehosting.net/uploads/286374c727.jpg

正如你可以看到沒有被正確地應用在左圖像上四角,但它們在2.2中看起來很完美。我使用的XML是在這裏:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item android:right="0dip" android:left="0dip" android:bottom="0dip" 
    android:top="0dip"> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <corners android:bottomRightRadius="3dip" 
      android:bottomLeftRadius="3dip" android:topLeftRadius="3dip" 
      android:topRightRadius="3dip" /> 
     <stroke android:width="1dip" android:color="#70532B" /> 
     <padding android:left="1dip" android:top="1dip" 
      android:right="1dip" android:bottom="1dip" /> 
    </shape> 
</item> 
<item android:right="0dip" android:left="0dip" android:bottom="0dip" 
    android:top="9dip"> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <gradient android:startColor="#ECAF08" android:endColor="#F6E34B" 
      android:angle="270" /> 
     <corners android:bottomRightRadius="3dip" 
      android:bottomLeftRadius="3dip" android:topLeftRadius="0dip" 
      android:topRightRadius="0dip" /> 

    </shape> 



</item> 
<item android:right="0dip" android:left="0dip" android:bottom="11dip" 
    android:top="0dip"> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
     android:shape="rectangle"> 
     <gradient android:startColor="#FCEF94" android:endColor="#FFBA00" 
      android:angle="270" /> 
     <corners android:bottomRightRadius="0dip" 
      android:bottomLeftRadius="0dip" android:topLeftRadius="3dip" 
      android:topRightRadius="3dip" /> 
    </shape> 
</item> 

我做錯了什麼,或者這是Android 2.1的一個bug ???

回答

2

聰明的方法來製作漸變按鈕。

我不知道這是否與<corners> xml在Android 2.1及更低版本中出現問題有關。 bottomLeftRadius實際上對應於bottomRightRadius,反之亦然。他們可能已經將它修正爲2.2,因此它在2.2中看起來是正確的,但是在2.1和更低版本中以意想不到的方式重疊。如果是這種情況,則可以使用針對版本的文件夾爲每個版本使用不同的繪圖板(即,/drawable-v7//drawable-v8/)。

+0

所以問題是,它看起來像你不能有一個矩形頂角和底角沒有角度。我以前見過這個問題。最後一次遇到它時,我找到了一個工作,基本上在矩形的頂部放置了一個矩形,從而將底部暴露出來,並使頂部保持平坦。這是hacky,但它的工作。 – Ben 2010-07-23 14:33:57

+1

另一件令人討厭的事情是你不能使用相對尺寸?即在我上面的例子中,你可能會注意到我分別有11和9的下降。它肯定會很好使用51%和49%或類似的東西...... – Ben 2010-07-23 14:38:42