AndroidUi(1)-直线

2016-09-21  本文已影响0人  C二叔

android中画线比较简单,常用的有实线和虚线

一.实线

Paste_Image.png
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="line">

<stroke  
android:width="2dp"  
android:color="#24cc0e"  />    

<!-- shape高度 -->    
<size android:height="10dp"  />

</shape>

二.虚线

Paste_Image.png
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"    android:shape="line">

<stroke  android:width="2dp"  
android:color="#24cc0e"        
android:dashGap="2dp"        
android:dashWidth="4dp" />    

<!-- shape高度 -->    
<size android:height="10dp" />

</shape>

Note:
stroke的android:width ,线的高度;
size的android:height,整个形状区域的高度;
引用虚线的view需要添加属性android:layerType="software"。

代码片段地址

上一篇 下一篇

猜你喜欢

热点阅读