如何在AnimationSet中同步单独的动画?

时间:2016-07-13 10:15:24

标签: android android-animation

我有一个mapFragment,我正在应用动画集。我正在寻找的效果如下 - "呼吸"动画。各个圈子正在扩张和褪色:

enter image description here

当前的动画代码可以:

enter image description here

看起来有点不同步。有什么方法可以实现更多的同步效果吗?

当前代码:

...
private AnimationSet breadingAnimations;


@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    breadingAnimations = new AnimationSet(true);
    breadingAnimations.restrictDuration(3000);
    breadingAnimations.setStartOffset(500);

}
...
@Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;


//Add smallest image drawable overlay

        Bitmap mDotMarkerBitmap1 = generateBitmapFromDrawable(R.drawable.circle_drawable);

        GroundOverlay groundOverlay1 = mMap.addGroundOverlay(new GroundOverlayOptions()
                .image(BitmapDescriptorFactory.fromBitmap(mDotMarkerBitmap1))
                .position(xDesign, 100));

        groundAnimation = new RadiusAnimation(groundOverlay1);
        groundAnimation.setRepeatCount(Animation.INFINITE);
        groundAnimation.setRepeatMode(Animation.RESTART);
        //        groundAnimation.setDuration(700);
        breadingAnimations.addAnimation(groundAnimation);


        Bitmap mDotMarkerBitmap2 = generateBitmapFromDrawable(R.drawable.circle_drawable2);
        GroundOverlay groundOverlay2 = mMap.addGroundOverlay(new GroundOverlayOptions()
                .image(BitmapDescriptorFactory.fromBitmap(mDotMarkerBitmap2))
                .position(xDesign, 100));

        Animation groundAnimation2 = new RadiusAnimation(groundOverlay2);
        groundAnimation2.setRepeatCount(Animation.INFINITE);
        groundAnimation2.setRepeatMode(Animation.RESTART);
        //        groundAnimation2.setDuration(900);
        breadingAnimations.addAnimation(groundAnimation2);


        Bitmap mDotMarkerBitmap3 = generateBitmapFromDrawable(R.drawable.circle_drawable3);
        GroundOverlay groundOverlay3 = mMap.addGroundOverlay(new GroundOverlayOptions()
                .image(BitmapDescriptorFactory.fromBitmap(mDotMarkerBitmap3))
                .position(xDesign, 100));
        Animation groundAnimation3 = new RadiusAnimation(groundOverlay3);
        groundAnimation2.setRepeatCount(Animation.INFINITE);
        groundAnimation2.setRepeatMode(Animation.RESTART);
        //        groundAnimation2.setDuration(1100);
        breadingAnimations.addAnimation(groundAnimation3);

        mapFragment.getView().startAnimation(breadingAnimations); // start animation

0 个答案:

没有答案