android mapbox:如何为标记设置动画,例如从屏幕顶部掉落的标记?
android mapbox: how can i animate markers, like marker falling from the top of screen?
我的目标是在地图上创建一个带有从屏幕顶部掉落动画的标记。
我不知道如何解决它。
我怎样才能做到这一点?
添加此方法:
private void dropPinEffect(final Marker marker) {
// Handler allows us to repeat a code block after a specified delay
final android.os.Handler handler = new android.os.Handler();
final long start = SystemClock.uptimeMillis();
final long duration = 1500;
// Use the bounce interpolator
final android.view.animation.Interpolator interpolator =
new BounceInterpolator();
// Animate marker with a bounce updating its position every 15ms
handler.post(new Runnable() {
@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
// Calculate t for bounce based on elapsed time
float t = Math.max(
1 - interpolator.getInterpolation((float) elapsed
/ duration), 0);
// Set the anchor
marker.setAnchor(0.5f, 1.0f + 14 * t);
if (t > 0.0) {
// Post this event again 15ms from now.
handler.postDelayed(this, 15);
} else { // done elapsing, show window
marker.showInfoWindow();
}
}
});
}
我的目标是在地图上创建一个带有从屏幕顶部掉落动画的标记。 我不知道如何解决它。 我怎样才能做到这一点?
添加此方法:
private void dropPinEffect(final Marker marker) {
// Handler allows us to repeat a code block after a specified delay
final android.os.Handler handler = new android.os.Handler();
final long start = SystemClock.uptimeMillis();
final long duration = 1500;
// Use the bounce interpolator
final android.view.animation.Interpolator interpolator =
new BounceInterpolator();
// Animate marker with a bounce updating its position every 15ms
handler.post(new Runnable() {
@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
// Calculate t for bounce based on elapsed time
float t = Math.max(
1 - interpolator.getInterpolation((float) elapsed
/ duration), 0);
// Set the anchor
marker.setAnchor(0.5f, 1.0f + 14 * t);
if (t > 0.0) {
// Post this event again 15ms from now.
handler.postDelayed(this, 15);
} else { // done elapsing, show window
marker.showInfoWindow();
}
}
});
}