我试过这里指定的几个答案,How do I make a dotted/dashed line in Android?如何使用xml绘制粗虚线?
但是线条都很薄。
我需要的是厚10倍的东西。感谢您从正确的答案阅读
码结果:
activity_main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.tester.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="20dp"
android:src="@drawable/dotted"
android:layerType="software"/>
</RelativeLayout>
dotted.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:dashGap="10px"
android:dashWidth="10px"
android:width="10dp"
android:color="@android:color/black"
/>
</shape>
这么愚蠢的问题! – Piyush
@Piyush,谨慎地阐述'愚蠢'的部分? –