Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alpha-gradient on Android

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

Image for example

like image 909
ftp27 Avatar asked Jan 15 '13 19:01

ftp27


People also ask

What is angle in gradient Android?

Gradient basically represents the variation in space(in a direction) of any quantity. With color it represents the variation of color intensity in a direction represented by angle.


1 Answers

Here the solution

the image look like below picture

enter image description here

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

like image 192
Dixit Patel Avatar answered Sep 20 '22 11:09

Dixit Patel