在XML中如何绘制实心圆内的小圆点?

3
我想在圆形内绘制小点。

enter image description here

这是我用于画带描边圆形的 XML 代码。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <stroke
        android:width="4dp"
        android:color="#444444" />
    <solid android:color="#FF0000" />
</shape>

enter image description here

1个回答

2
使用 layer-list 标签
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Large red circle -->
<item>
    <shape
        android:shape="oval">
        <stroke
            android:width="1dp"
            android:color="#000000" />
        <solid android:color="#FF0000" />
        <size
            android:width="40dp"
            android:height="40dp"/>
    </shape>
</item>

<!-- Small black circle -->
<item android:right="3dp"
    android:left="-3dp"
    android:top="3dp"
    android:bottom="-3dp">
    <shape android:shape="oval">
        <stroke android:color="@android:color/transparent"
            android:width="35dp"/>
        <solid android:color="#000"/>
        <size
            android:width="5dp"
            android:height="5dp"/>
    </shape>
</item>

修改您选择的边距和大小


我尝试了这个,但仍然得到相同的红色圆圈和黑色描边。我在您的评论下面添加了以下代码:<item> <shape android:shape="oval"> <size android:height="3dp" android:width="3dp"/> <solid android:color="#444444"/> - Zohra Khan
我更新了答案。看看吧。我认为那就是你想要的。 - Nikoloz Akhvlediani

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接