我正在使用Google Maps Api,而我正在使用自定义标记。我想将滑动动画设置为标记。
因此,如果用户单击标记,标记滑动的一部分将隐藏在其余部分的下方。当点击动画隐藏的部分将反转时。
像图像一样:
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>
然后我尝试了onMapReady方法:
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;
});
但是动画没有发生。以前有没有人做过类似的事情?