0

我想显示下载 gif 文件。

并使用 GifAnimationDrawable 进行处理。

它在仿真中运行。不在其他设备上。未播放的 gif 图像。

没有难点出错。

public void showGifView(InputStream input){
                final GifAnimationDrawable drawable;
                try {
                    drawable = new GifAnimationDrawable(input, true);


                    act.runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            // TODO Auto-generated method stub


                            view.setBackground(drawable);
                            AnimationDrawable frameAnimation = (AnimationDrawable) view.getBackground();
                            frameAnimation.start();

                        //view.setImageDrawable(drawable);//drawable.start();

                        }
                    });



                    input.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    System.out.println("showGifView  //// " +  e);
                }

            }
4

2 回答 2

0

为什么不用 Glide 来显示?

String filePath = "/storage/emulated/0/Pictures/amin1.gif";

Glide  
    .with( context )
    .load( Uri.fromFile( new File( filePath ) ) )
    .into( imageViewGif );
于 2015-11-24T02:01:50.700 回答
0

您也可以使用Bumptech 的 Glide,因为它们还支持加载 gif 图像。
你可以像这样使用它

Glide.with(this)
        .load(url)
        .into(myImageView);

并使用它添加到你的 gradle 文件

dependencies {
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.android.support:support-v4:19.1.0'
}
于 2015-11-24T02:02:22.847 回答