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

グライドを使って表示してみませんか?

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

gif 画像の読み込みにも対応しているので、bumptech の Glide を使用することもできます。
こんな感じで使えます

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 に答える