android dashed border with padding

2019-06-16 19:27发布

i have a RadioGroup RadioGroup I would like to add a dashed stroke(boder?) with some padding.

The background of Radio Buton is

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/navigation"/>
    <item >
        <shape>
            <solid android:color="#00000000"/>
            <stroke android:color="#ffffff"
                    android:dashGap="5dp"
                    android:dashWidth="5dp"/>
        </shape>
    </item>
</layer-list>

The second item - is my attemp to draw dashed line.

What am i doing wrong?

2条回答
做个烂人
2楼-- · 2019-06-16 19:37

I think this will help you.

try this.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape>
            <solid android:color="#ffffff" />
            <stroke
                android:dashGap="5dp"
                android:dashWidth="5dp"
                android:width="1dp"
                android:color="#0000FF" />
            <padding
                android:bottom="5dp"
                android:left="5dp"
                android:right="5dp"
                android:top="5dp" />
        </shape>
    </item>
</layer-list>
查看更多
不美不萌又怎样
3楼-- · 2019-06-16 19:50

Try adding android:width="1dip" to your <stroke> tag.

查看更多
登录 后发表回答