Commonly used, record it.
Rendering:
First create a new xml file bg_gradient.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <gradient android:startColor="#55FF0000" android:centerColor="#99A73C3C" android:endColor="#99000000" android:angle="270" /> <corners android:radius="0dip" /> </shape>
Quote in the layout file
android:background="@drawable/bg_gradient"
More android For related articles on the method of realizing color gradient of background images, please pay attention to the PHP Chinese website!