Apply gradient to Android View

Images have loat of memory than using colur. We also need different size images for different resolutions, so in Android we can use gradient that shade the color.

We can apply gradient to different Views in Android like EditText, TextView or Button etc.
It will be take less memory.

In your Android project add new xml filed in drawable folder.



I name this new xml to “rect_view”, and add some code for gradient.

This file will look like this

we can change our desire colors, angle and conrner.

Finaly apply this file as background to any View like Button.

We can assign this shape to more than one different views.

Our output will like this.