小编aNo*_*Guy的帖子

教程 - Android Map Pin drop动画 - 正常工作

我需要我的Android应用程序的地图引脚下拉动画.做了很多研究,我没有发现任何有用的东西.所以我创造了一个小黑客.只需发布代码,以便其他人可以使用它并相应地修改它.

由于Android中的翻译动画仅适用于视图而叠加不是视图,我创建了一个小的黑客,它通过翻译动画将视图放在同一个地理位置,然后删除视图以显示叠加.这样,用户认为地图叠加层从顶部开始掉落,即使它们不是.

这是代码:

private void translateAnimation(MapView mapView,ArrayList<GeoPoint> geoPointsList,Context context) {
    Point dropPoint = new Point();
    Projection projection = mapView.getProjection(); /*
                                                      * Getting the map projections to calculate
                                                      * screen points and geopoints
                                                      */
    GeoPoint mGeoPoint = projection.fromPixels(0, 0);

    /* Map View screen parameters */
    MapView.LayoutParams screenParameters = new MapView.LayoutParams(
            MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT, mGeoPoint, 0,
            0, MapView.LayoutParams.LEFT | MapView.LayoutParams.BOTTOM);

    for (GeoPoint geoPoint : geoPointsList) {
        projection.toPixels(geoPoint, dropPoint); /*
                                                   * As Overlays are not a subclass of views so
                                                   * view animation cannot …
Run Code Online (Sandbox Code Playgroud)

android overlay android-animation android-mapview

11
推荐指数
0
解决办法
3707
查看次数