Some Kotlin Problem with solutions Every developer need to know

Create UberCar Animation with Android Library

How to Add Uber Car Animation in Android
How to Add Uber Car Animation in Android
I found a question on Quora about How to add Uber car animation in Android application. I really like this question and found a solution which help you if want to do this in your application.

Solution is UberCarAnimation is an Android library which showing movement of car on map like in Uber.

  • Parse the “overview_polyline” from the JSON by providing the appropriate GET parameters. For eg:
"" +
+ "transit_routing_preference=less_driving&"
+ "origin=" + latitude + "," + longitude + "&"
+ "destination=" + destination + "&"
+ "key=" + getResources().getString(R.string.google_directions_key)

  • Decode the polyline which will provide you with list of latitudes and longitudes that is List<LatLng> to be apt.
  • Create a value animator by providing the ofFloatValue, setting duration and adding update listener in Handler
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator valueAnimator) {

  • Finally set position of marker to the new position, also evaluating the bearing between the consecutive points so that it seems car is turning literally and finally update camera as:
marker.setAnchor(0.5f, 0.5f);
marker.setRotation(getBearing(startPosition, newPos));
(new CameraPosition.Builder()

See full article: Add Uber Car Animation Android