Leo*_*iki 5 android google-maps
我正在尝试google map使用特定的Lat-Lng 设置涟漪动画,请看到这完全描述了我想要的内容,我在上面提到链接但无法设置动画google map.
我到目前为止所尝试的是 -
我的xml代码:
<com.test.custom.RippleBackground
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rippleLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
app:rb_color="#0099CC"
app:rb_duration="5000"
app:rb_radius="32dp"
app:rb_rippleAmount="4"
app:rb_scale="6" >
<ImageView
android:id="@+id/imgMapProfile"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_centerInParent="true"
android:src="@drawable/ic_profile_active" />
</com.test.custom.RippleBackground>
Run Code Online (Sandbox Code Playgroud)
我的Java代码在谷歌地图上放置涟漪:
LatLng currentAddressLatLong;
currentAddressLatLong = new LatLng(gps.getLatitude(), gps.getLongitude());
RippleBackground rippleLayout=(RippleBackground)findViewById(R.id.rippleLayout);
rippleLayout.setVisibility(View.VISIBLE);
ImageView imgMapProfile=(ImageView)findViewById(R.id.imgMapProfile);
Bitmap markerUserBitmap = Comman.createDrawableFromView(NearByActivity.this, rippleLayout);
googleMap.addMarker(new MarkerOptions().position(currentAddressLatLong).icon(BitmapDescriptorFactory.fromBitmap(markerUserBitmap)));
googleMap.moveCamera(CameraUpdateFactory.newLatLng(currentAddressLatLong));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(11));
rippleLayout.startRippleAnimation();
// Convert a view to bitmap function
public static Bitmap createDrawableFromView(Context context, View view)
{
DisplayMetrics displayMetrics = new DisplayMetrics();
((Activity)context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
view.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
view.measure(displayMetrics.widthPixels, displayMetrics.heightPixels);
view.layout(0, 0, displayMetrics.widthPixels, displayMetrics.heightPixels);
view.buildDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
return bitmap;
}
Run Code Online (Sandbox Code Playgroud)
但是位图没有动画.请帮忙.非常感谢.
小智 10
对于想要在谷歌地图中创建涟漪背景的每个人都这样 
Run Code Online (Sandbox Code Playgroud)new Handler().postDelayed(new Runnable() { @Override public void run() {final GroundOverlay groundOverlay11=googleMap.addGroundOverlay(new GroundOverlayOptions() .position(latLng, 2000) .transparency(0.5f) .image(BitmapDescriptorFactory.fromResource(R.drawable.krug))); OverLay(groundOverlay11); } }, 0);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
final GroundOverlay groundOverlay1=googleMap.addGroundOverlay(new GroundOverlayOptions()
.position(latLng, 2000)
.transparency(0.5f)
.image(BitmapDescriptorFactory.fromResource(R.drawable.krug)));
OverLay(groundOverlay1);
}
}, 4000);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
final GroundOverlay groundOverlay2=googleMap.addGroundOverlay(new GroundOverlayOptions()
.position(latLng, 2000)
.transparency(0.5f)
.image(BitmapDescriptorFactory.fromResource(R.drawable.krug)));
OverLay(groundOverlay2);
}
}, 8000);
Run Code Online (Sandbox Code Playgroud)
和叠加类:
public void OverLay(final GroundOverlay groundOverlay){
vAnimator = ValueAnimator.ofInt(0, 2000);
int r=99999;
vAnimator.setRepeatCount(r);
//vAnimator.setIntValues(0, 500);
vAnimator.setDuration(12000);
vAnimator.setEvaluator(new IntEvaluator());
vAnimator.setInterpolator(new LinearInterpolator());
vAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedFraction = valueAnimator.getAnimatedFraction();
Integer i = (Integer) valueAnimator.getAnimatedValue();
groundOverlay.setDimensions(i);
}
});
vAnimator.start();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3791 次 |
| 最近记录: |