点划线的两种实现方法

点划线的两种实现方法看效果图 第一条线是图片效果 第二条线是 sharp 实现的 1 图片效果实现方法 布局文件 bg line xml xml version 1 0 encoding utf 8

大家好,我是讯享网,很高兴认识大家。

看效果图,第一条线是图片效果,第二条线是sharp实现的


讯享网

1 图片效果实现方法:

布局文件:bg_line.xml

<?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android"  android:src="@drawable/asr_dashed"  android:tileMode="repeat"  />

讯享网

引用:

讯享网<View  android:layout_width="match_parent"  android:layout_height="3px"  android:background="@drawable/bg_line"  app:layout_auto_basewidth="height"  />

图片文件只能放在drawable目录下


2  sharp实现方法:

布局文件:shape_line.xml

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"  android:shape="line" >  <!-- 描边 -->  <stroke android:width="2px"  android:color="@color/asr_circle_text"  android:dashWidth="15px"  android:dashGap="10px"  />  </shape>

引用:

讯享网<View  android:layout_width="match_parent"  android:layout_height="3px"  android:background="@drawable/shape_line"  app:layout_auto_basewidth="height"  android:layerType="software"  />

注意:

android:layerType="software"


小讯
上一篇 2025-02-18 07:10
下一篇 2025-01-07 20:09

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/47600.html