Android如何设置渐变色背景 渐变shape

Android如何设置渐变色背景
Android开发过程中,会用到android:backgroud属性来设置背景的颜色,一般情况下我们直接设置一个类似#FFFF0000的值代表是背景颜色,如果想设置渐变背景颜色,就需要用到gradient了。

我们分:线性渐变、放射渐变、扫描渐变,下面具体看下:

一、线性渐变
线性渐变也是默认的渐变色,比如我们设置一个最简单的效果,代码如下:

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

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_39170886/article/details/126977470