Rak*_*esh 5 android android-animation
我想以编程方式为视图的顶部地图填充设置动画,但我不知道如何执行此操作.
private GoogleMap map;
map.setPadding(left, top, right, bottom);
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何动画top填充值从0到100?
Upv*_*ote 14
地图填充不是视图属性,也不是对象属性.您可以通过为地图视图添加填充来测试它:
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"/>
Run Code Online (Sandbox Code Playgroud)
结果是地图本身是填充的,不同于
map.setPadding(left, top, right, bottom);
Run Code Online (Sandbox Code Playgroud)
setPadding是一种抵消地图内UI控件的方法.没有动画属性.幸运的是,android提供了ValueAnimator.您的问题可以通过这种方式解决:
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();
Run Code Online (Sandbox Code Playgroud)
这基本上是动画从0到paddingBottom的整数,没有任何上下文.您可以在onAnimationUpdate侦听器中创建上下文,并将动画填充值分配给地图填充.
| 归档时间: |
|
| 查看次数: |
3430 次 |
| 最近记录: |