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

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

问题描述

我需要在ImageView的边缘创建一个alpha渐变。最好只使用XML。




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

Image for example

解决方案

Here the solution

the image look like below picture

code for that:

  • Prepare shape drawable

res/drawable/gradient_shape.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
            android:startColor="#00FFFFFF"
            android:endColor="#FFFFFFFF"
            android:type="linear" />
</shape>

Define layout: activity_main.xml:

<ImageView
    android:id="@+id/photo"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/photo"
    android:src="@drawable/gradient_shape" />

here drawable/photo is just jpeg in drawables folder

EDIT for more information refer this Tutorial

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

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