如何绘制可绘制线条的圆形破折号或圆点

问题描述 投票:0回答:2

是否有一种方法可以使大写的圆点/圆点如上图所示?

enter image description here

<shape
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="line">

    <stroke 
    android:width="2dp"
    android:color="@color/grey"
    android:dashWidth="3dp"
    android:dashGap="3dp" />

</shape>

[伙计们,我知道如何制作虚线,我在问如何制作“四舍五入”的破折号!!看看来自Adobe XD的这张照片,就知道我的意思..!

enter image description here

java android android-layout android-drawable xml-drawable
2个回答
0
投票

尝试一下

我已经编辑了长度,间隙宽度和高度,看起来与您在屏幕快照中提到的相同

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">
    <stroke
        android:dashGap="5dp"
        android:dashWidth="15dp"
        android:width="5dp"
        android:color="@color/grey" />
</shape>

输出

enter image description here


0
投票

为此,您必须制作drawable/dotted.xml:文件并按如下所示将此形状添加到其中

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

<stroke
android:color="@color/grey"
android:dashWidth="10px"
android:dashGap="10px"
android:width="1dp" />
</shape>

并将其添加到ImageView的背景中,如下所示

<ImageView
    android:layout_width="match_parent"
    android:layout_height="5dp"
    android:src="@drawable/dotted"
    android:layerType="software" />
© www.soinside.com 2019 - 2024. All rights reserved.