Android利用shape畫虛線html
咱們知道,想在Android XML中畫出一條直線,很簡單: <View android:layout_width="match_parent" android:layout_height="1px" android:background="#FFFFFF"/> 若是想要畫出一條虛線呢? 在drawable目錄下新建bg_dash_line.xmljava
<?xml version="1.0" encoding="utf-8"?>android
<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時,就是實線 注意:xml