使android自定义drawable

时间:2015-02-22 19:21:34

标签: android android-drawable

drawable

如何创建一个匹配给定布局高度的drawable?我知道我必须在一个drawable中创建一些多种形状,但我有点迷失在这里。

2 个答案:

答案 0 :(得分:2)

尝试2个椭圆形状和一条线的图层列表。然后设置为视图的背景。我不确定它是否有效。

您还可以使用9补丁:read this

答案 1 :(得分:0)

它应该适用于xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:paddingTop="4dp">
    <item>
        <rotate android:fromDegrees="90" android:gravity="center_horizontal" android:toDegrees="90">
            <shape android:shape="line">
                <stroke android:color="#000000" android:width="1dp"/>
            </shape>
        </rotate>
    </item>
    <item android:gravity="center_horizontal|top" android:height="8dp" android:width="8dp">
        <shape android:shape="oval">
            <solid android:color="#000000"/>
        </shape>
    </item>
    <item android:gravity="center_horizontal|bottom" android:height="4dp" android:width="4dp">
        <shape android:shape="oval">
            <solid android:color="#000000"/>
        </shape>
    </item>
</layer-list>