2

Android: ShapeDrawablexmlで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 に答える