0
点赞
收藏
分享

微信扫一扫

Android通过代码实现虚线或者虚线框shape

上古神龙 2022-08-23 阅读 207


虚线

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:width="1dp"
android:color="#f3f3f3"
android:dashWidth="3dp"
android:dashGap="3dp"
</shape>

虚线框

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="#f3f3f3"
android:dashWidth="3dp"
android:dashGap="3dp"
</shape>

虚线圆

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="1dp"
android:color="#f3f3f3"
android:dashWidth="3dp"
android:dashGap="3dp"
</shape>

顶部虚线

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-2dp"
android:right="-2dp"
android:bottom="-2dp">
<shape>
<stroke
android:width="1dp"
android:color="#f3f3f3"
android:dashWidth="3dp"
android:dashGap="3dp"
</shape>
</item>
</layer-list>

底部虚线

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<stroke
android:width="1dp"
android:color="#f3f3f3"
android:dashWidth="3dp"
android:dashGap="3dp"
</shape>
</item>
</layer-list>

使用

android:background="@drawable/shape_dash_line"


举报

相关推荐

0 条评论