I want to achieve a marker animation such as GIF animation. I got two images which should be blinking simultaneously. I found nothing which can acheive this in android. I am trying to do is , creating a handler which run every 1 second , and I am trying to set icon for marker. But it doesnt work. Please guide me in right direction.
my code as of now is as follows.
Handler handler = new Handler();
Boolean marker_color_bool = true;
//adding marker and sending the marker instance to marker_animation() method where handler is called.
MarkerOptions marker = new MarkerOptions()
.title(delivery_center_name)
.snippet("This is the " + delivery_center_name + " location")
.position(location)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.red_marker));
google_map.addMarker(marker);
marker_animation(marker);
marker_animation() method
private final int ONE_SECONDS = 1000;
public void marker_animation(final MarkerOptions marker ) {
handler.postDelayed(new Runnable() {
public void run() {
Log.e("running",""+marker_color_bool);
if(marker_color_bool == true)
{
marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.green_marker));
marker_color_bool = false;
}
else
{
marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.red_marker));
marker_color_bool = true;
}
handler.postDelayed(this, ONE_SECONDS);
}
}, ONE_SECONDS);
}
this approach doesnt work..Please help me what I am doing wrong.