Android开发之渐变色,你学会了吗?
2024-01-16 10:14:57 软件 227观看
摘要android.graphics中提供了有关Gradient类,包含LinearGradient线性渐变、 RadialGradient径向渐变和SweepGradient梯度渐变,它们的继承自android.graphics.Shader。LinearGradient 线性渐变LinearGradient(float x0, flo

android.graphics中提供了有关Gradient类,包含LinearGradient线性渐变、 RadialGradient径向渐变和SweepGradient梯度渐变,它们的继承自android.graphics.Shader。bhV28资讯网——每日最新资讯28at.com

LinearGradient 线性渐变

LinearGradient(float x0, float y0, float x1, float y1, int[] colors, float[] positions, Shader.TileMode tile)LinearGradient(float x0, float y0, float x1, float y1, int color0, int color1, Shader.TileMode tile)

参数bhV28资讯网——每日最新资讯28at.com

说明bhV28资讯网——每日最新资讯28at.com

x0bhV28资讯网——每日最新资讯28at.com

渐变线起点的x坐标bhV28资讯网——每日最新资讯28at.com

y0bhV28资讯网——每日最新资讯28at.com

渐变线起点的y坐标bhV28资讯网——每日最新资讯28at.com

x1bhV28资讯网——每日最新资讯28at.com

渐变线末端的x坐标bhV28资讯网——每日最新资讯28at.com

y1bhV28资讯网——每日最新资讯28at.com

渐变线末端的y坐标bhV28资讯网——每日最新资讯28at.com

colorsbhV28资讯网——每日最新资讯28at.com

沿着渐变线分布的颜色数组bhV28资讯网——每日最新资讯28at.com

color0bhV28资讯网——每日最新资讯28at.com

渐变线开始处的颜色bhV28资讯网——每日最新资讯28at.com

color1bhV28资讯网——每日最新资讯28at.com

渐变线末端的颜色bhV28资讯网——每日最新资讯28at.com

positionsbhV28资讯网——每日最新资讯28at.com

颜色数组中每个对应颜色的相对位置[0,1]。如果为null,则颜色沿线均匀分布bhV28资讯网——每日最新资讯28at.com

tilebhV28资讯网——每日最新资讯28at.com

着色器平铺模式bhV28资讯网——每日最新资讯28at.com

Paint paint =new Paint();//两个坐标形成变量,规定了渐变的方向和间距大小,着色器为镜像LinearGradient linearGradient =new LinearGradient(0,0,200,0, Color.RED,Color.BLUE, Shader.TileMode.MIRROR);paint.setShader(linearGradient);paint.setStrokeWidth(50);canvas.drawLine(0,getMeasuredHeight()/2,getMeasuredWidth(),getMeasuredHeight()/2, paint);

图片图片bhV28资讯网——每日最新资讯28at.com

RadialGradient 径向/放射渐变

RadialGradient(float x, float y, float radius, int[] colors, float[] positions, Shader.TileMode tile)RadialGradient(float x, float y, float radius, int color0, int color1, Shader.TileMode tile)

参数bhV28资讯网——每日最新资讯28at.com

说明bhV28资讯网——每日最新资讯28at.com

xbhV28资讯网——每日最新资讯28at.com

半径中心的x坐标bhV28资讯网——每日最新资讯28at.com

ybhV28资讯网——每日最新资讯28at.com

半径中心的y坐标bhV28资讯网——每日最新资讯28at.com

radiusbhV28资讯网——每日最新资讯28at.com

渐变的圆的半径bhV28资讯网——每日最新资讯28at.com

colorsbhV28资讯网——每日最新资讯28at.com

颜色分布在圆的中心和边缘之间bhV28资讯网——每日最新资讯28at.com

color0bhV28资讯网——每日最新资讯28at.com

圆圈中心的颜色bhV28资讯网——每日最新资讯28at.com

color1bhV28资讯网——每日最新资讯28at.com

圆圈边缘的颜色bhV28资讯网——每日最新资讯28at.com

positionsbhV28资讯网——每日最新资讯28at.com

颜色数组中每个对应颜色的相对位置[0,1]。如果为null,则颜色沿线均匀分布bhV28资讯网——每日最新资讯28at.com

tilebhV28资讯网——每日最新资讯28at.com

着色器平铺模式bhV28资讯网——每日最新资讯28at.com

paint =new Paint();radialGradient =new RadialGradient(240,360,200, new int[]{Color.BLUE, Color.GREEN, Color.RED },null, Shader.TileMode.CLAMP);paint.setShader(radialGradient);canvas.drawCircle(240,360,200,paint);

图片图片bhV28资讯网——每日最新资讯28at.com

SweepGradient 扫描/梯度/扇形渐变

SweepGradient(float x, float y, int[] colors, float[] positions)SweepGradient(float x, float y, int color0, int color1)

参数bhV28资讯网——每日最新资讯28at.com

说明bhV28资讯网——每日最新资讯28at.com

xbhV28资讯网——每日最新资讯28at.com

中心的x坐标bhV28资讯网——每日最新资讯28at.com

ybhV28资讯网——每日最新资讯28at.com

中心的y坐标bhV28资讯网——每日最新资讯28at.com

colorsbhV28资讯网——每日最新资讯28at.com

颜色分布在中心周围,阵列中必须至少有2种颜色bhV28资讯网——每日最新资讯28at.com

color0bhV28资讯网——每日最新资讯28at.com

扫描开始时使用的颜色bhV28资讯网——每日最新资讯28at.com

color1bhV28资讯网——每日最新资讯28at.com

扫描结束时使用的颜色bhV28资讯网——每日最新资讯28at.com

positionsbhV28资讯网——每日最新资讯28at.com

颜色数组中每个对应颜色的相对位置[0,1]。如果为null,则颜色沿线均匀分布bhV28资讯网——每日最新资讯28at.com

paint =new Paint();int[] colors = new int[]{Color.GREEN, Color.GREEN, Color.BLUE, Color.RED, Color.RED};sweepGradient = new SweepGradient(240, 360,colors,null);paint.setShader(sweepGradient);canvas.drawCircle(x,y,200,paint);

图片图片bhV28资讯网——每日最新资讯28at.com

本文链接:http://www.28at.com/showinfo-26-62356-0.htmlAndroid开发之渐变色,你学会了吗?

声明:本网页内容旨在传播知识,不代表本站观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。

显示全文

上一篇:阿里二面:要保证消息不丢失,又不重复,消息队列怎么选型?

下一篇:Spring Boot:如何快速集成Mybatis和Thymeleaf

最新热点