Android Design 相关
首先看一下要怎么实现水平的虚分割线:
在 drawable 文件下建立 line_dotted_horizontal.xml
1 2 3 4 5 6 7 8 9 10
| <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line">
<stroke android:color="#C7B299" android:dashGap="6px" android:dashWidth="6px"/>
</shape>
|
按如下方式引用:
1 2 3 4 5
| <View xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="1px" android:background="@drawable/line_dotted_horizontal" android:layerType="software"/>
|
注意:需要添加 android:layerType=”software” 否则在有些设备上仍然显示实线
垂直的虚线
drawable 下新建 line_dotted_vertical.xml
填上参考一下
1 2 3 4 5 6 7 8 9 10 11 12
| <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:left="-300dp" android:right="-300dp"> <rotate android:drawable="@drawable/line_dotted_horizontal" android:fromDegrees="90" android:toDegrees="90" android:visible="true"/> </item> </layer-list>
|
或者
1 2 3 4 5
| <?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:drawable="@drawable/line_dotted_horizontal" android:fromDegrees="90" android:toDegrees="90"/>
|
参考列表
Creating horizontal and vertical dotted lines in android
How to create vertical dashed line divider using xml in Android?
Pro tip: Add a dashed line in an Android layout
画个虚线箭头连接引导2个View