Android 上的 Alpha 渐变 [英] Alpha-gradient on Android

查看:28
本文介绍了Android 上的 Alpha 渐变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I need to create an alpha-gradient on the edge of the ImageView. Preferably using only XML.

Image for example

解决方案

Need to code a custom ImageView if you want colorless transparency.

If your background is a static color, here's my preferred workaround:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/your_image"/>

    <item>
        <shape android:shape="rectangle">
            <gradient android:startColor="#00efefef"
                android:endColor="#ffefefef"
                android:angle="270"
                android:type="linear"/>
        </shape>
    </item>
</layer-list>

这篇关于Android 上的 Alpha 渐变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆