2

ShapeDrawableAndroid:有没有办法在 xml中指定 a 的宽度和高度?这似乎异常困难。使用的<size>子级不起作用,将其包装<shape>在图层列表项以及设置android:heightandroid:weight属性中也不起作用。

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<!-- 
How do you set shape size?
The top/bottom attributes allow setting size via an inset
from the parent element, but isn't there way to explicitly
set width and height???
-->
    <item
        android:bottom="0dp"
        android:left="0dp"
        android:right="0dp"
        android:top="0dp">
        <shape android:shape="rectangle" >
            <solid android:color="#f00" />
            <stroke
                android:width="1dp"
                android:color="#0f0" />
        </shape>
    </item>

</layer-list>
4

1 回答 1

0

size并且padding标签始终在shape标签下可用。请重新检查您的代码。

<item>
    <shape android:shape="rectangle">
        <solid android:color="#FFFFFF" />
        <size android:height="4dp" android:width="15dp" />
        <padding android:left="2dp" android:top="2dp" android:right="2dp" android:bottom="2dp" />
    </shape>
</item>
于 2014-03-04T08:17:10.323 回答