美文网首页
Android 背景颜色渐变

Android 背景颜色渐变

作者: 因为我的心 | 来源:发表于2020-12-17 09:37 被阅读0次

一、前言:

效果展示:


展示图.png

实现步骤:

1、在res/drawable中创建一个名称background_gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- 实现颜色渐变-->
    <gradient
        android:startColor="#FF9100"
        android:endColor="#FF6600"
        android:angle="0"
        />
</shape>
2、在你的界面xml中按下面写,就可以实现界面背景颜色渐变效果了。
android:background="@drawable/background_gradient"
3、关于android:angle的参数说明如下:

android:angle="0"//效果是:是从左到右,按照开始颜色到结束颜色来渲染的
android:angle="90"//效果是:是从下到上,按照开始颜色到结束颜色来渲染的
android:angle="180"//效果是:是从右到左,按照开始颜色到结束颜色来渲染的
android:angle="270"//效果是:是从上到下,按照开始颜色到结束颜色来渲染的

相关文章

网友评论

      本文标题:Android 背景颜色渐变

      本文链接:https://www.haomeiwen.com/subject/dhbagktx.html