ImageView:如何在图标前面绘制一个灰色圆圈?

时间:2016-02-16 15:14:24

标签: android android-imageview

正如您在屏幕截图中看到的,我的左侧有一个图标current

如何在布局xml中左侧图标的正面绘制一个灰色圆圈,如下面的屏幕截图所示?

屏幕截图enter image description here

2 个答案:

答案 0 :(得分:3)

你可以试试这个;

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

答案 1 :(得分:1)

创建这个可绘制的

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

然后将其作为图像视图的背景,并将X作为imageview的src

圆圈是图像背后的可绘制物。

这样你可以重复使用drawable并放入几个图标