使用评估动画在谷歌地图上进行圆圈动画,但动画一直闪烁并一直闪烁。
这是一段代码,
CircleOptions circleOptions = new CircleOptions()
.center(searchStopPoint) //set center
.radius(100) //set radius in meters
.strokeColor(Color.TRANSPARENT)
.fillColor(0x555751FF)
.strokeWidth(5);
busStopCircle = googleMap.addCircle(circleOptions);
ValueAnimator valueAnimator = new ValueAnimator();
valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setRepeatMode(ValueAnimator.RESTART);
valueAnimator.setIntValues(0, 100);
valueAnimator.setDuration(3000);
valueAnimator.setEvaluator(new IntEvaluator());
valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedFraction = valueAnimator.getAnimatedFraction();
busStopCircle.setRadius(animatedFraction * 100);
}
});
valueAnimator.start();
任何人都可以帮我制作流畅的动画而不会闪烁..
由于
答案 0 :(得分:5)
这是known issue。一种解决方法是使用GroundOverlay而不是圆圈
这是一个例子:
创建圆圈:
// The drawable to use for the circle
GradientDrawable d = new GradientDrawable();
d.setShape(GradientDrawable.OVAL);
d.setSize(500,500);
d.setColor(0x555751FF);
d.setStroke(5, Color.TRANSPARENT);
Bitmap bitmap = Bitmap.createBitmap(d.getIntrinsicWidth()
, d.getIntrinsicHeight()
, Bitmap.Config.ARGB_8888);
// Convert the drawable to bitmap
Canvas canvas = new Canvas(bitmap);
d.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
d.draw(canvas);
// Radius of the circle
final int radius = 100;
// Add the circle to the map
final GroundOverlay circle = map.addGroundOverlay(new GroundOverlayOptions()
.position(searchStopPoint, 2 * radius).image(BitmapDescriptorFactory.fromBitmap(bitmap)));
现在为圆形叠加设置动画:
ValueAnimator valueAnimator = new ValueAnimator();
valueAnimator.setRepeatCount(ValueAnimator.INFINITE);
valueAnimator.setRepeatMode(ValueAnimator.RESTART);
valueAnimator.setIntValues(0, radius);
valueAnimator.setDuration(3000);
valueAnimator.setEvaluator(new IntEvaluator());
valueAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedFraction = valueAnimator.getAnimatedFraction();
circle.setDimensions(animatedFraction * radius * 2);
}
});
valueAnimator.start();
更新:此问题has been fixed