2012-04-14 46 views
4

我想要的是背景與紅色部分在左邊。像這樣的東西。 enter image description here設置Android Drawable項目的寬度?

我試了很多東西(沒有任何所見即所得的編輯器嗎?我覺得我跑這幾百倍。)指定寬度喜歡在下面的文章沒有工作。 how to specify width and height of a drawable item

下面的文章只告訴我,我不能使用百分比,現在如何應用寬度。 Android Drawable: Specifying shape width in percent in the XML file?

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 

      <shape> 
       <solid 
       android:color="#FFFFFFFF"/> 
      </shape> 

    </item> 
    <item> 

      <shape android:shape="rectangle"> 
       <solid android:color="#55FF0000" /> 
       <size android:width="100px" /> 
      </shape> 

    </item> 

</layer-list> 

回答

2

您指定使用繪製資源的ImageView或其他控件的寬度。 <shape>後面的點爲而不是指定了一個大小,所以它可以在運行時應用於各種大小。

+0

我有同樣的問題。所以我該怎麼做? – shift66 2014-08-22 15:14:42