我想以编程方式对视图的顶部地图填充进行动画处理,但我不知道如何执行此操作。
private GoogleMap map;
map.setPadding(left, top, right, bottom);
任何人都知道如何制作动画top
填充值从0到100?
地图填充不是视图属性,也不是对象属性。您可以通过为地图视图提供填充来测试它:
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"/>
结果是地图本身被填充,这与
map.setPadding(left, top, right, bottom);
setPadding
是一种在地图内偏移 UI 控件的方法。没有可设置动画的属性。幸运的是 android 提供了值动画器 http://developer.android.com/guide/topics/graphics/prop-animation.html#value-animator。您的问题可以这样解决:
ValueAnimator animation = ValueAnimator.ofInt(0, paddingBottom);
animation.setDuration(150);
animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
getMap().setPadding(0, 0, 0, Integer.parseInt(valueAnimator.getAnimatedValue().toString()));
}
});
animation.start();
这基本上是在没有任何上下文的情况下将整数从 0 动画到 paddingBottom。您可以在 onAnimationUpdate 侦听器中创建上下文,在其中将动画填充值分配给地图填充。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)