2012-04-14 125 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