【发布时间】:2016-01-13 09:20:12
【问题描述】:
Fill star with partially Picture
看上图。 我的示例代码如下
`protected void onDraw(Canvas canvas) { 中=getWidth()/2; int a=100,b=100; min = Math.min(a, b); 脂肪 = 最小 / 17; 一半 = 分钟 / 2; 弧度 = 5; mid = 中 - 一半;
paint = new Paint();
paint.setColor(Color.BLUE);
paint.setStyle(Paint.Style.STROKE);
Path path = new Path();
path.reset();
paint.setStyle(Paint.Style.FILL);
// top left
path.moveTo(half * 0.5f, half * 0.84f);
// top right
path.lineTo(half * 1.5f, half * 0.84f);
// bottom left
path.lineTo(half * 0.68f, half * 1.45f);
// top tip
path.lineTo(half * 1.0f, half * 0.5f);
// bottom right
path.lineTo(half * 1.32f, half * 1.45f);
// top left
path.lineTo(half * 0.5f, half * 0.84f);
path.close();
canvas.drawPath(path, paint);
super.onDraw(canvas);
}`
我的问题是我们如何在android中部分填充star?
我想要这个填充选项不仅有半填充星。
而且,如果我们考虑全星长度是 100%。
我们必须填充 20% 的星长,或者我们必须填充 50% 的星长,或者我们必须填充 70% 的星长。
填充星的任何填充值。
【问题讨论】:
标签: android android-layout canvas draw paint