安卓开发之渐变色背景

在drawble包下,新建xml文件:

<?xml version="1.0" encoding="utf-8"?>

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <gradient
            android:angle="135"
            android:centerX="0.5"
            android:centerY="0.5"
            android:endColor="#ffeb3b"
            android:startColor="#fff59d"
            android:type="linear" />
    </shape>

在控件的调用:

android:background=@drawble/xml文件名
原文地址:https://www.cnblogs.com/adressian/p/10461274.html