Zohra Khan
Zohra Khan

Reputation: 5302

How to draw small circle/dot within a solid circle in XML?

I want to draw small dot within a circle.

enter image description here

This is my XML code for circle with stroke.

<?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

Upvotes: 3

Views: 4100

Answers (1)

Nikoloz Akhvlediani
Nikoloz Akhvlediani

Reputation: 403

use layer-list tag

<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>

Modify margins and sizes of your choice

Upvotes: 2

Related Questions