ausgeführt werden Ich versuche, eine Atmeffektanimation auf meinem MapFragment zu erzielen, aber aus irgendeinem Grund kann ich nicht mehrere Animationen auf der Karte ausführen. Was ich versuche zu erreichen ist so etwas wie dieses:Nultuple Animationen können nicht auf GroundOverlay [GoogleMap]
Und die Kreise erweitern allmählich und Verblassen zu tun. Gerade jetzt meine Animation tut dies:
die nicht ganz ist, was ich will. Der aktuelle Code (wenn ich die 2 Blöcke mit den Handlern auskommentiere) macht nur eine Animation und der Rest der Formen bleibt stationär. EDIT Ich habe herausgefunden, was passiert - die "startAnimation" -Methode überschreibt die aktuelle Animation. Jetzt frage ich mich, ob es einen Weg gibt, wie ich dieses Übersteuern vermeiden kann? Irgendwelche Ideen ?:
Dies ist mein Code:
@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 und 3 gleich außer der Breite & Höhenwerte, sie sind größer 60 und 90dp und die Farben - blau und rot):
<?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 Klasse:
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);
}
}
Ich versuche, genau die gleiche Animation zu erzielen, wie Sie erwähnten. Ich habe Ihren Code als Referenz verwendet, aber ich habe einige Probleme. Ich sehe die Animation überhaupt nicht. Nicht sicher, was ich falsch mache. – Neha
Ich habe Angst, dass ich nicht mehr für die gleiche Firma arbeite, also habe ich keinen Zugriff mehr auf den Code, den ich benutzt habe. Der Code hier ist die einzige Quelle, die ich habe, um die Animation zu erreichen. Ich erinnere mich, dass es für mich aber funktionierte :) –
ok, keine probs. Vielen Dank :) – Neha