您的位置:首页 > 移动开发 > Android开发

android利用shape画虚线

2016-06-01 16:07 337 查看
我们知道,想在Android XML中画出一条直线,很简单:
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#FFFFFF"/>



如果想要画出一条虚线呢?

在drawable目录下新建bg_dash_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="3px"
android:color="#FFFFFF"
android:dashWidth="10px"
android:dashGap="10px" />
</shape>


说明:

显示一条虚线,width为线条的高度,dashWidth为破折线的宽度,dashGap为破折线之间的空隙的宽度,当dashGap=0时,就是实线
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: