Android Eclipse:类似GIF的位图
如何在不更改位图方向的情况下使位图Android Eclipse:类似GIF的位图,android,eclipse,bitmap,gif,sprite,Android,Eclipse,Bitmap,Gif,Sprite,如何在不更改位图方向的情况下使位图设置动画?它与移动的GIF图片一样。但是很多论坛都说使用GIF是不好的。那么,我怎样才能使我的位图像GIF一样工作呢?提前谢谢,对于这样一个不太有用的问题,请道歉 这是我使用的代码: portal = BitmapFactory.decodeResource(getResources(), R.drawable.add_portal1); portal = Bitmap.createScaledBitmap(portal, Bitwidth,
设置动画?它与移动的GIF图片一样。但是很多论坛都说使用GIF是不好的。那么,我怎样才能使我的位图像GIF一样工作呢?提前谢谢,对于这样一个不太有用的问题,请道歉
这是我使用的代码:
portal = BitmapFactory.decodeResource(getResources(), R.drawable.add_portal1);
portal = Bitmap.createScaledBitmap(portal, Bitwidth,
Bitheight, true);
canvas.drawBitmap(portal, (mazeFinishX1 * totalCellWidth)
+ (cellWidth / 20), (mazeFinishY1 * totalCellHeight)
+ (cellWidth / 20), ball);
.gif
只是一系列帧在计时器上播放,通常是重复播放。您需要将.gif中的所有帧作为drawable
资源,按顺序播放,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame_animation"
android:oneshot="false" >
<item
android:drawable="@drawable/frame_1"
android:duration="200"/>
<item
android:drawable="@drawable/frame_2"
android:duration="200"/>
<item
android:drawable="@drawable/frame_3"
android:duration="200"/>
<item
android:drawable="@drawable/frame_2"
android:duration="200"/>
</animation-list>
将布局充气后。谢谢您的帮助,先生。但是如何将它插入到我的画布.drawBitmap
?因为我已经设置了位图的大小及其在游戏中的位置。我只是想把它做成动画
像gif
一样。画布绘图更难。您将需要在特定时间更新并选择特定的可绘制资源。讨论画布及其工作原理。在StackOverflow评论中很难输入更具体的答案。
ImageView animation = (ImageView) v.findViewById(R.id.iv_bouncer);
animation.setBackgroundResource(R.drawable.simple_bounce_frames);