围绕位图绘制渐变透明圆



我从文件中得到了一个位图,我需要能够在它周围绘制一个渐变(逐渐变得更加透明)。我该怎么做?我环顾四周,找不到什么。

指向正确的方向会有所帮助,谢谢。

-编辑-

我想用程序来做这件事,比如用位图类和画布。

我画了一幅画来说明我的问题。(仍然坚持):https://i.stack.imgur.com/9aFMu.jpg

您可以在xml中执行此操作。

<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape android:shape="rectangle" >
            <!-- end colour at top, start colour at bottom -->
            <!-- Your colors can include hex alpha values --> 
            <!-- #ff000000 is fully transparent black -->
            <!-- #00000000 is non transparent black -->
            <!-- There are more options in that link to control the gradient more -->
            <gradient
                android:type="radial"
                android:endColor="@color/endColor" 
                android:startColor="@color/startColor"/>
        </shape>
    </item>
    <!-- top, bottom left and right adds padding -->
    <item android:bottom="3px">
        <Bitmap src="@drawable/yourBitmap />
    </item>
</layer-list>

这里有一个很棒的链接,提供了有关xml可绘制文件的更多信息。http://idunnolol.com/android/drawables.html

最新更新