我可以在一个图形页面使用AnimationDrawable在覆盖? [英] Can I use AnimationDrawable in an overlay on a MapView?

查看:184
本文介绍了我可以在一个图形页面使用AnimationDrawable在覆盖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了XML的AnimationDrawable,并能正常工作。但在移动可绘制成图形页面作为覆盖标记(更换静态的绘制工作正常),动画顽固地拒绝播放。我搬到了调用start(),以一个按钮,用于测试,即使pressed几秒钟的MapView已经显示后,动画将不会启动。我看到没有在logcat中。我知道开始()需要调用后,所有的窗户都设置了,但是这似乎是一个单独的问题。

是AnimationDrawables与MapView的兼容?

有没有我需要做的,使在一个图形页面一部作品一些特别的东西?

你曾经成功有一个工作在图形页面?

解决方案

使用马特的解决方案(下)我加了AnimationDrawable通过将ImageView的的MapView的层内,而不是使用的叠加。

 公共无效showAnimatedMarker(的GeoPoint点){
    的LinearLayout V =(的LinearLayout)View.inflate(背景下,R.layout.markerlayout,NULL);
    ImageView的标记=(ImageView的)v.findViewById(R.id.marker);
    AnimationDrawable markerImage =(AnimationDrawable)marker.getDrawable();
    this.addView(V,0,新MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT,点,MapView.LayoutParams.BOTTOM_CENTER));
    markerImage.start();
}
 

然后markerlayout.xml:

 < XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    >
    < ImageView的
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:ID =@ + ID /标记
            机器人:SRC =@可绘制/ my_animation_drawable
    />
< / LinearLayout中>
 

解决方案

这是未经测试与动画,但可能是一些使用。

我有问题,将小工具添加到图形页面,却发现addView方法。尝试通过这种方法加入AnimationDrawable,它可能会改变它是如何的MapView处理,因此正确的动画

看一看这里的一个小例子: 的http://www.gauntface.co.uk/pages/blog/2010/01/04/mapview-with-widgets-android/

I have created an AnimationDrawable in XML, and it works fine. But on moving the drawable into a MapView as an overlay marker (replacing a static drawable that works fine), the animation stubbornly refuses to play. I've moved the call to start() to a button, for testing, and even when pressed several seconds after the MapView has displayed, the animation doesn't start. I'm seeing nothing in logcat. I know start() needs calling after all the windows are set up, but this seems to be a separate issue.

Are AnimationDrawables compatible with MapView?

Is there something special I need to do to make one work in a MapView?

Have you ever successfully had one work in a MapView?

Solution

Using Matt's solution (below) I added the AnimationDrawable by putting the ImageView inside the MapView's layers, rather than using an overlay.

public void showAnimatedMarker(GeoPoint point) {
    LinearLayout v = (LinearLayout) View.inflate(context, R.layout.markerlayout, null);
    ImageView marker = (ImageView) v.findViewById(R.id.marker);
    AnimationDrawable markerImage = (AnimationDrawable)marker.getDrawable();
    this.addView(v, 0, new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, point, MapView.LayoutParams.BOTTOM_CENTER));
    markerImage.start();
}

And then markerlayout.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
    <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/marker"
            android:src="@drawable/my_animation_drawable"
    />
</LinearLayout>

解决方案

This is untested with animations, but may be of some use.

I had issues with adding widgets to the MapView, but found the addView method. Try adding the AnimationDrawable through this method, it may change how it is treated by the MapView and hence animate correctly:

Have a look here for a tiny example: http://www.gauntface.co.uk/pages/blog/2010/01/04/mapview-with-widgets-android/

这篇关于我可以在一个图形页面使用AnimationDrawable在覆盖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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