最近项目风格走的卡片风,运用了许多渐变背景,虽然可以利用点9图可以进行拉伸,但是跟设计师调图也是蛮费劲,所以利用drawable中的gradient 画一个背景,记录一下.

首先放一张效果图:


线性渐变


梯度渐变

代码:

        android:angle="integer"

        android:centerX="integer"

        android:centerY="integer"

        android:centerColor="integer"

        android:endColor="color"

        android:gradientRadius="integer"

        android:startColor="color"

        android:type=["linear" | "radial" | "sweep"]

        android:useLevel=["true" | "false"] />


android:angle="integer"

Integer,代表渐变颜色的角度, 0 is left to right, 90 is bottom to top. 必须是45的整数倍. 

默认值0, 在type = "linear"下起作用. 默认情况是从左到右渐变 

android:startColor="# f8c62f"

 android:endColor="# 119dff"

 android:centerColor=" #FF4081t"

分别是 渐变色中的开始颜色  结束颜色  中间的渐变颜色

android:centerX

Float.(0-1.0) 相对X的渐变位置

android:centerY

Float.(0-1.0) 相对Y的渐变位置

这两个属性只有在不是 type = "linear" 的情况下才起作用 

android:gradientRadius

Float. 渐变色的半径,单位应该是像素点. 需要 android:type="radial":

android: type

"linear"  : 线性渐变. 大概为 y= ax+b;

"radial" : 圆形渐变,起始颜色从cenralX,centralY 点开始

"sweep" : 梯度渐变

更多相关文章

  1. Android:shape的使用详解(1)
  2. 【Android(安卓)应用开发】Android资源文件 - 使用资源存储字符
  3. Android属性大全之shape
  4. Android中shape使用
  5. 安卓中的shape
  6. Android:shape的使用详解(1)
  7. [置顶] Android学好Shape不再依赖美工
  8. Android(安卓)TextView显示文字过长时添加阴影渐变消失效果
  9. Android里面常用的Drawable的使用

随机推荐

  1. C语言打印数据的二进制格式-原理解析与编
  2. Linux makefile使用基础
  3. Linux gdb使用基础
  4. Linux gcc使用基础
  5. 2021-02-27:假设一个固定大小为W的窗口,依
  6. TensorFlow-平面曲线拟合
  7. TensorFlow-VGG16模型复现
  8. TensorFlow-手写数字识别(三)
  9. TensorFlow-手写数字识别(二)
  10. 安卓10