Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Eclipse:类似GIF的位图_Android_Eclipse_Bitmap_Gif_Sprite - Fatal编程技术网

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);