如何在动画的android图填充 [英] How to animate map padding in android

查看:189
本文介绍了如何在动画的android图填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望以编程动画视图的顶部地图填充,但我不知道如何做到这一点。

I want to animate top map padding of a view programmatically but I have no idea how to do this.

private GoogleMap map;
map.setPadding(left, top, right, bottom);

任何人有一个想法如何从动画填充值的发言权0到100?

Anyone have an idea how to animate top padding value from say 0 to 100 ?

推荐答案

地图填充是不是视图属性,也不是一个对象的属性。您可以通过给填充到地图视图测试:

The map padding is not a view property nor a object property. You can test it by giving a padding to the map view:

<com.google.android.gms.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="10dp"/>

其结果是,在地图本身被填充而不同从

The result is that the map itself is padded which is different from

 map.setPadding(left, top, right, bottom);

setPadding 是抵消了地图内的UI控件的方法。没有产权的动画。幸运的是,Android提供的<一个href=\"http://developer.android.com/guide/topics/graphics/prop-animation.html#value-animator\">ValueAnimator.你的问题是可以解决的是这样的:

setPadding is a method that offsets the UI controls inside the map. There is no property to animate. Luckily android offers the ValueAnimator. You problem can be solved this way:

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的背景下。

This basically animates an integer from 0 to paddingBottom without any context. You create the context in the onAnimationUpdate listener where you assign the animated padding value to the map padding.

这篇关于如何在动画的android图填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆