0

내 MapFragment에서 호흡 효과 애니메이션을 얻으려고하고 있지만 어떤 이유로지도에서 여러 애니메이션을 실행할 수 없습니다. 무엇을 달성하려고하면이 같은 것입니다 :GroundOverlay에서 nultuple 애니메이션을 실행할 수 없습니다. [GoogleMap]

enter image description here

을 그리고 원은 점차 확대하고 사라져 그렇게하고 있습니다. 지금 내 애니메이션은이 일을한다 : 내가 원하는 것을 확실히하지

enter image description here

합니다. 현재 코드 (처리기로 2 블록의 주석 처리를 제거한 경우)는 하나의 애니메이션 만 수행하고 나머지 셰이프는 고정되어 있습니다. 편집 "startAnimation"메서드가 현재 애니메이션을 재정의하고 있습니다. 이제 어떻게하면이 재정의를 피할 수있는 방법이 있는지 궁금합니다. 어떤 아이디어? 이건 내 코드입니다

enter image description here

:

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

//Add smallest image drawable overlay 

     mDotMarkerBitmap = generateBitmapFromDrawable(R.drawable.circle_drawable); 
     groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() 
       .image(BitmapDescriptorFactory.fromBitmap(mDotMarkerBitmap)) 
       .position(xDesign, 100)); 
     groundAnimation = new RadiusAnimation(groundOverlay); 
     groundAnimation.setRepeatCount(Animation.INFINITE); 
     groundAnimation.setRepeatMode(Animation.RESTART); 
     groundAnimation.setDuration(2000); 
     mapFragment.getView().startAnimation(groundAnimation); // MapView where i show my map 
//TODO Fix the animation tomorrow 
//Add medium size image drawable overlay 

//  new Handler().postDelayed(new Runnable() { 
//   @Override 
//   public void run() { 
//    // your code here 
//    mDotMarkerBitmap = generateBitmapFromDrawable(R.drawable.circle_drawable2); 
//    groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() 
//      .image(BitmapDescriptorFactory.fromBitmap(mDotMarkerBitmap)) 
//      .position(xDesign, 100)); 
//    groundAnimation = new RadiusAnimation(groundOverlay); 
//    groundAnimation.setRepeatCount(Animation.INFINITE); 
//    groundAnimation.setRepeatMode(Animation.RESTART); 
//    groundAnimation.setDuration(10000); 
//    mapFragment.getView().startAnimation(groundAnimation); // MapView where i show my map 
//   } 
//  }, 1000/* 1sec delay */); 

// 
////Add smallest size image drawable overlay 
//  new Handler().postDelayed(new Runnable() 
//  { 
//   @Override 
//   public void run() 
//   { 
//    // your code here 
//    mDotMarkerBitmap = generateBitmapFromDrawable(R.drawable.circle_drawable3); 
//    groundOverlay = mMap.addGroundOverlay(new GroundOverlayOptions() 
//      .image(BitmapDescriptorFactory.fromBitmap(mDotMarkerBitmap)) 
//      .position(xDesign, 100)); 
//    groundAnimation = new RadiusAnimation(groundOverlay); 
//    groundAnimation.setRepeatCount(Animation.INFINITE); 
//    groundAnimation.setRepeatMode(Animation.RESTART); 
//    groundAnimation.setDuration(2000); 
//    mapFragment.getView().startAnimation(groundAnimation); // MapView where i show my map 
//   } 
//  }, 1000/* 1sec delay */); 



     mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(xDesign, 15)); 
    } 

circle_drawable.xml (circle_drawable2와 3 폭 & 높이 값 exept 같은, 그들은 60 크고 90dp이며,

<?xml version="1.0" encoding="utf-8"?> 
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="oval"> 
    <solid 
     android:color="#0093e8"/> 
    <size 
     android:width="30dp" 
     android:height="30dp"/> 
</shape> 

RadiusAnimation 클래스 :

01) 파란색과 빨간색 - 색상
public class RadiusAnimation extends Animation { 
    private GroundOverlay groundOverlay; 

    public RadiusAnimation(GroundOverlay groundOverlay) { 
     this.groundOverlay = groundOverlay; 

    } 
    @Override 
    protected void applyTransformation(float interpolatedTime, Transformation t) { 
     groundOverlay.setDimensions((100 * interpolatedTime)); 
     groundOverlay.setTransparency(interpolatedTime); 

    } 


    @Override 
    public void initialize(int width, int height, int parentWidth,int parentHeight) { 
     super.initialize(width, height, parentWidth, parentHeight); 
    } 
} 

답변

0

누군가 비슷한 일을 시도하는 경우에 해결책을 찾았습니다. 여러 애니메이션을 동시에 실행하려면 AnimationSet을 사용할 수 있습니다. 그래서 개별 애니메이션을 지연시키는 핸들러를 제거했지만 각 애니메이션이 마지막 애니메이션을 오버라이드하고 있기 때문에 작동하지 않아 마지막으로 mapFragment에서 재생 된 것을 보았습니다. 그래서 내 코드를 다음과 같이 변경했습니다.

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 


     mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(xDesign, 15)); 
    } 
+0

언급 한 것과 똑같은 애니메이션을 얻으려고합니다. 참조 용으로 코드를 사용했지만 몇 가지 문제가 있습니다. 애니메이션이 전혀 보이지 않습니다. 내가 뭘 잘못하고 있는지 모르겠다. – Neha

+0

나는 더 이상 같은 회사에서 일하지 않기를 바라고 있으며, 따라서 나는 더 이상 내가 사용한 코드에 접근 할 수 없다. 여기에있는 코드가 애니메이션을 완성해야하는 유일한 소스입니다. 나는 그것이 나를 위해 일했다고 생각한다 :) –

+0

괜찮아, probs. 감사 :) – Neha

관련 문제