I'm using Google Maps Api and 'm using custom marker. I want to set sliding animation to marker.
So user if click to marker, a part of marker sliding hide under the remaining part. When the part of hidden if click animation will reversed.
So like this as images :
left_to_right_anim.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="-100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
</set>
right_to_left.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700" />
</set>
And I tried in onMapReady method:
mGoogleMap.setOnMarkerClickListener(marker -> {
mCurrLocationMarker.remove();
if (!isMarkerPure) {
AnimationUtil.slideRightToLeft(mCurrLocationMarker, rootView.getContext());
mCurrLocationMarker = mGoogleMap.addMarker(markerOptions.position(latLng).icon(BitmapDescriptorFactory
.fromBitmap(getPureMarker(R.drawable.cengiz)))
.anchor(0.5f, anchorY));
isMarkerPure = true;
} else {
AnimationUtil.slideLeftToRight(mCurrLocationMarker, rootView.getContext());
mCurrLocationMarker = mGoogleMap.addMarker(markerOptions.position(latLng).icon(BitmapDescriptorFactory
.fromBitmap(getMarkerBitmapFromView(R.drawable.cengiz, locName, name)))
.anchor(0.125f, anchorY));
isMarkerPure = false;
}
return false;
});
But animation didn't happen. Has anyone ever done anything like that before?
from Android Google Maps sliding animation to Marker


No comments:
Post a Comment