首页 > 系统 > Android > 正文

Android画一条虚线

2019-11-09 17:48:27
字体:
来源:转载
供稿:网友
首先在drawable里面创建一个xml文件  代码如下
<?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="#aaaaaa" 		android:dashGap="3dp" 		android:dashWidth="3dp" /> </shape>

然后在控件里面引用这个样式

示例如下

<View 	android:id="@+id/dotted_line" 	android:layout_width="match_parent" 	android:layout_height="5dp"	android:background="@drawable/bg_dotted_line" 	android:layerType="software" 	/>提示:一定要加
android:layerType="software" 这一句


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表