Gif not animated in custom listview

独自空忆成欢 提交于 2019-12-02 19:48:38
sokie

You can use Android Movie class that is able to decode gifs.

Movie.decodeStream(InputStream is);

Use WebView rather then ImageView and loadUrl in WebView.

you have to use gif decorder class for that and set it in inflact view so you can set two view in single activity or screen.

Use the Glide image loading library, it has built-in support for GIFs and the syntax is the same loading a JPEG file:

Glide.with(this).load("http://.../anim.gif").into(imageView);

See the wiki for more and run the Gihpy sample to be amazed :)

Android
//-----------------GIF Image view ------------

holder.imgAdd.getSettings().setJavaScriptEnabled(true);

holder.imgAdd.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress)
    {
        activity.setTitle("Loading...");
        activity.setProgress(progress * 100);

        if(progress == 100)
            activity.setTitle(R.string.app_name);
    }
});

holder.imgAdd.setWebViewClient(new WebViewClient() {
    @Override
    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
    {
        // Handle the error
    }
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url)
    {
        view.loadUrl(url);
        return true;
    }
});

            holder.imgAdd.loadUrl(imgUrl);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!