Skip to content

Commit

Permalink
修复Android4.4.4以下版本中无法显示动画的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuRi committed Jan 3, 2017
1 parent 97f5998 commit 0796c80
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void paint(Canvas canvas, float playProgress) {
measure.setPath(path, false);
// 根据实验,发现对号的路径长度占总长度的26%,所以下面减去0.26
measure.getSegment((float) Math.max(0, playProgress - 0.26) * measure.getLength(), playProgress * measure.getLength(), disPath, true);
disPath.rLineTo(0, 0);// 解决在android4.4.4以下版本导致的无法绘制path的bug
canvas.drawPath(disPath, paint);
}
});
Expand Down Expand Up @@ -116,6 +117,7 @@ public void paint(Canvas canvas, float playProgress) {
PathMeasure measure = new PathMeasure();
measure.setPath(path, false);
measure.getSegment((float) Math.max(0, playProgress - 0.16) * measure.getLength(), playProgress * measure.getLength(), disPath, true);
disPath.rLineTo(0, 0);// 解决在android4.4.4以下版本导致的无法绘制path的bug
canvas.drawPath(disPath, paint);

Path pathRight = new Path();
Expand All @@ -126,6 +128,7 @@ public void paint(Canvas canvas, float playProgress) {
PathMeasure measureRight = new PathMeasure();
measureRight.setPath(pathRight, false);
measureRight.getSegment((float) Math.max(0, playProgress - 0.16) * measureRight.getLength(), playProgress * measureRight.getLength(), disPathRight, true);
disPathRight.rLineTo(0, 0);// 解决在android4.4.4以下版本导致的无法绘制path的bug
canvas.drawPath(disPathRight, paint);
}
});
Expand Down Expand Up @@ -190,6 +193,7 @@ public void paint(Canvas canvas, float playProgress) {
measure.setPath(path, false);
// 截取线段起到渐长渐短的效果:进度的2次方 作为起点,根号2的进度作为终点
measure.getSegment((float) (Math.pow(playProgress, 2) * measure.getLength()), (float) (Math.sqrt(playProgress) * measure.getLength()), disPath, true);
disPath.rLineTo(0, 0);// 解决在android4.4.4以下版本导致的无法绘制path的bug
canvas.drawPath(disPath, paint);
}
});
Expand Down

0 comments on commit 0796c80

Please sign in to comment.