zoukankan      html  css  js  c++  java
  • android 渐变drawable

    渐变Drawable它是使用<gradient>的标记的形状Drawable定义子节点的定义。

    每个梯度Drawable求至少要有一个startColor和endColor属性,而且支持一个可选的middleColor属性。

    通过使用type属性,能够把渐变定义为下面的某种类型:

    线性:这是默认的渐变类型,它显示了依照angle属性定义的角度从startColor到endColor的直接颜色过渡。

    辐射:从形状的外边界到中心绘制从startColor到endColor的圆形渐变。

    扫描:绘制一个扫描渐变,它将沿着父形状(一般是一个圆环)的外边界从startColor到endColor进行过渡。

    1.在res下新建drawable目录。

    2.在drawable目录下新建xml文件。

    3.在组件的bacground属性里引用此文件。

    以下是线性的代码和效果:

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
        android:shape="rectangle"
        android:useLevel="false"
        >
        <gradient 
            android:startColor="#ffffff"
            android:endColor="#ffffff"
            android:centerColor="#000000"
            android:useLevel="false"
            android:type="linear"
            android:angle="45"
            />
    </shape>
    



    辐射渐变的椭圆

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

    > <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" android:useLevel="false" > <gradient android:type="radial" android:startColor="#ffffff" android:endColor="#ffffff" android:centerColor="#000000" android:useLevel="false" android:gradientRadius="300" /> </shape>




    扫描渐变:

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
        android:shape="ring"
        android:useLevel="false"
        android:innerRadiusRatio="3"
        android:thicknessRatio="8"
        >
        <gradient 
            android:startColor="#ffffff"
            android:endColor="#ffffff"
            android:centerColor="#000000"
            android:useLevel="false"
            android:type="sweep"
            />
        
    
    </shape>
    <!-- 扫描渐变的椭圆 -->


    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    深入Spring之IOC之加载BeanDefinition
    Hexo+GitHub Actions 完美打造个人博客
    Spring中资源的加载原来是这么一回事啊!
    Web 跨域请求问题的解决方案- CORS 方案
    重新认识 Spring IOC
    Spring Data Jpa 入门学习
    前奏:Spring 源码环境搭建
    最短路径——floyd算法代码(c语言)
    leetcode 第184场周赛第一题(数组中的字符串匹配)
    如何用尾插法建立双链表(C语言,非循环)
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4688392.html
Copyright © 2011-2022 走看看