Android 尝试设置背景虚线,但结果为下划线
我尝试将虚线设置为项目Android 尝试设置背景虚线,但结果为下划线,android,shape,Android,Shape,我尝试将虚线设置为项目 <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:color="#100901" android:dashWidth="10px" android:dashGap="10px" android:width="1dp"/
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">
<stroke
android:color="#100901"
android:dashWidth="10px"
android:dashGap="10px"
android:width="1dp"/>
</shape>
在androidstudio中,我认为一切都是正确的。但在实际应用中,我看不到虚线和下划线
改用可绘制的图层列表
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="2dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="#100901"
android:dashGap="10px"
android:dashWidth="10px" />
</shape>
</item>
</layer-list>
改用可绘制的图层列表
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="2dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape>
<solid android:color="@android:color/transparent" />
<stroke
android:width="1dp"
android:color="#100901"
android:dashGap="10px"
android:dashWidth="10px" />
</shape>
</item>
</layer-list>
您可以通过此实现
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/triangleup"
android:tileMode="repeat"
android:tint="@color/lightAccent"/>
这里的三角形是您的虚线图像
快乐编码 你可以通过这个来实现
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/triangleup"
android:tileMode="repeat"
android:tint="@color/lightAccent"/>
这里的三角形是您的虚线图像
快乐编码