赞
踩
最近在做的项目中遇到做圆形、半圆形ProgressBar,先分享给大家
主要用到类:
一、Android RectF类的构造函数参数说明
以下是API中的说明:
public RectF (float left, float top, float right, float bottom)
Added in API level 1
Create a new rectangle with the specified coordinates. Note: no range checking is performed, so the caller must ensure that left <= right and top <= bottom.
Parameters
left The X coordinate of the left side of the rectangle
top The Y coordinate of the top of the rectangle
right The X coordinate of the right side of the rectangle
bottom The Y coordinate of the bottom of the rectangle
比如new一个RecF类:
RectF rf1 = new RectF(100,100,200,200);
则在屏幕中的位置示意图为:
二、SweepGradient的说明与使用
主要实现圆形可颜色渐变进度条
public SweepGradient(float cx, float cy, int[] colors, float[] positions)
Parameters:
cx 渲染中心点x 坐标
cy 渲染中心y 点坐标
colors 围绕中心渲染的颜色数组,至少要有两种颜色值
positions 相对位置的颜色数组,可为null, 若为null,可为null,颜色沿渐变线均匀分布
public SweepGradient(float cx, float cy, int color0, int color1)
Parameters:
cx 渲染中心点x 坐标
cy 渲染中心点y 坐标
color0 起始渲染颜色
color1 结束渲染颜色
三、Canvas
public void draw
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。