'现在我正在 Phonegap 框架中开发应用程序。我的问题是动画图像正在显示但没有动画。在浏览器中它工作正常。在模拟器中只显示图像。 我该如何解决这个问题?
最佳答案
private static class GIFView extends View{
Movie movie;
InputStream is=null;
long moviestart;
public GIFView(Context context)
{
super(context);
is=context.getResources().openRawResource(R.drawable.smile);
movie=Movie.decodeStream(is);
}
@Override
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
long now=android.os.SystemClock.uptimeMillis();
if (moviestart == 0) { // first time
moviestart = now;
}
int relTime = (int)((now - moviestart) % movie.duration()) ;
movie.setTime(relTime);
movie.draw(canvas,100,100);
this.invalidate();
}
}
使用这个类并将 View 添加到您的布局中,
GIFView view=new GIFView(this);
linear=(LinearLayout)findViewById(R.id.linear);
linear.addView(view);
可能对你有帮助..
关于android - 动画 Gif 图像在 Phonegap 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7384587/