Glide 加載Gif 圖,正常加載不出來,將GIF轉(zhuǎn)流加載

有時候不需要添加 .asGif () 也可以加載gif 動畫,加上.asGif () 效果可能會充滿屏幕

            Resources res = getResources();
            int id= R.mipmap.twtx01;

            InputStream is = null;

            try {
                final TypedValue value = new TypedValue();
                is = res.openRawResource(id, value);
                ByteArrayOutputStream outStream = new ByteArrayOutputStream ();
                byte[] data = new byte[4048];
                int count = -1;
                while((count = is.read(data,0,4048)) != -1)
                    outStream.write(data, 0, count);
                Glide.with (iv_mrzb.getContext ())
                        .load (outStream.toByteArray ())
                        .asGif ()
                        .placeholder (R.mipmap.sign_after_001) //
//                .diskCacheStrategy(DiskCacheStrategy.NONE)
                        .error (R.mipmap.sign_after_001)
                        .into (iv_mrzb);

            } catch (Exception e) {
            /*  do nothing.
                If the exception happened on open, bm will be null.
                If it happened on close, bm is still valid.
            */
            } finally {
                try {
                    if (is != null) is.close();
                } catch (IOException e) {
                    // Ignore
                }
            }

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容