美文网首页工作生活
Android shape渐变颜色

Android shape渐变颜色

作者: 黑芝麻胡 | 来源:发表于2019-07-03 17:16 被阅读0次

1、在resource文件夹的drawable文件中新建一个shape的xml文件

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

  //android:angle="45"      渐变的方向 默认为0 从做向右 ,90时从下向上 必须为45的整数倍
  //  android:type="radial"       渐变类型 有三种 线性linear 放射渐变radial 扫描线性渐变sweep
  //  android:centerX="0.5"       渐变中心相对X坐标只有渐变类型为放射渐变时有效
  //  android:centerY="0.5"       渐变中心相对Y坐标只有渐变类型为放射渐变时有效
  //  android:gradientRadius="100"    渐变半径 非线性放射有效

    <gradient
        android:angle="0"//从左到友渐变
        android:endColor="#FF38C9"//结束颜色
        android:startColor="#B463FF" />//开始颜色

</shape>

效果图


$(EIU8@(HT2N2~SR50AC51L.png

相关文章

网友评论

    本文标题:Android shape渐变颜色

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