Ralf Wickum
Ralf Wickum

Reputation: 3270

ImageView: How to draw a grey circle in front of a icon?

As you can see on the screenshots, I have a icon current on the left side of this.

How can I draw a grey circle on the front of that left icon in the layout xml, as in following screenshot?

Screenshot enter image description here

Upvotes: 0

Views: 1910

Answers (2)

xanexpt
xanexpt

Reputation: 753

create this drawable

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

   <solid 
       android:color="#666"/>
</shape>

then put it as background of the image view, and put the X as the src of imageview

The circle is the drawable that is behind the image.

This way you can reutilize the drawable and put in several icons

Upvotes: 1

caliskan
caliskan

Reputation: 107

You can try this;

<?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape android:shape="oval">
                <solid android:color="#BCBCBC" />
            </shape>
        </item>
        <item android:top="1dp" android:left="1dp" android:right="1dp" android:bottom="1dp" android:drawable="@drawable/your_cross_icon">
            <shape android:shape="oval">
                <solid android:color="#BCBCBC" />
            </shape>
        </item>
    </layer-list>

Upvotes: 4

Related Questions