android -- 加载gif 防止oom
项目中涉及到gif图片的展示,原来使用的是gifview,但是当频繁的,加载过大图片的时候会出现OOM的问题,后来去github上面找相关的库:
https://github.com/koral--/android-gif-drawable
android-gif-drawable是比较好的,并能尽最大可能避免oom的库
下面讲下如何导入和使用该库:

这些事so文件,必须导入;还有就是引入jar包:

然后xml文件里面:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loading_view"
android:layout_width="match_parent"
android:layout_height="match_parent" > <pl.droidsonroids.gif.GifImageView
android:id="@+id/iv_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dimen_48dp" /> <TextView
android:id="@+id/tv_iv_nonet_bg1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/iv_loading"
android:layout_centerHorizontal="true"
android:text="加载中.."
android:textColor="@color/color_A3A3A3" /> </RelativeLayout>
注意红色部位就是对应加载gif图片的控件GifImageView
下面看下代码中如何使用:
GifImageView gifView = (GifImageView) findViewById(R.id.iv_loading);
gifView.setImageResource((R.drawable.search_loading_bg));
第二行就是加载drawable的代码,至于其他用法,看该库github
android -- 加载gif 防止oom的更多相关文章
- Android加载大图不OOM
首先,我们试着往sdcard里放一张400k的图片,但是分辨率是2560*1600 布局简单 <?xml version="1.0" encoding="utf-8 ...
- Android加载大图片OOM异常解决
尽量不要使用setImageBitmap或setImageResource或BitmapFactory.decodeResource来设置一张大图, 因为这些函数在完成decode后,最终都是通过 ...
- [android]加载大量图片避免OOM
原理是事先取得图片的长宽,直接读出缩略图. BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferr ...
- Android加载/处理超大图片神器!SubsamplingScaleImageView(subsampling-scale-image-view)【系列1】
Android加载/处理超大图片神器!SubsamplingScaleImageView(subsampling-scale-image-view)[系列1] Android在加载或者处理超大巨型图片 ...
- android加载大量图片内存溢出的三种方法
android加载大量图片内存溢出的三种解决办法 方法一: 在从网络或本地加载图片的时候,只加载缩略图. /** * 按照路径加载图片 * @param path 图片资源的存放路径 * @para ...
- android加载gif图片
Android加载GIF图片的两种方式 方式一:使用第三开源框架直接在布局文件中加载gif 1.在工程的build.gradle中添加如下 buildscript { repositories { m ...
- 漂亮的Android加载中动画:AVLoadingIndicatorView
AVLoadingIndicatorView 包含一组漂亮的Android加载中动画. IOS版本:here. 示例 Download Apk 用法 步骤1 Add dependencies in b ...
- 8. Android加载流程(打包与启动)
移动安全的学习离不开对Android加载流程的分析,包括Android虚拟机,Android打包,启动流程等... 这篇文章 就对Android的一些基本加载进行学习. Android虚拟机 And ...
- React-Native 之 GD (二十)removeClippedSubviews / modal放置的顺序 / Android 加载git图\动图 / 去除 Android 中输入框的下划线 / navigationBar
1.removeClippedSubviews 用于提升大列表的滚动性能.需要给行容器添加样式overflow:’hidden’.(Android已默认添加此样式)此属性默认开启 这个属性是因为在早期 ...
随机推荐
- 线段树练习 3&&P3372 【模板】线段树 1
题目描述 Description 给你N个数,有两种操作: 1:给区间[a,b]的所有数增加X 2:询问区间[a,b]的数的和. 输入描述 Input Description 第一行一个正整数n,接下 ...
- 教你成为全栈工程师(Full Stack Developer) 〇-什么是全栈工程师
作为一个编码12年的工程师老将,讲述整段工程师的往事,顺便把知识都泄露出去,希望读者能少走一些弯路. 这段往事包括:从不会动的静态网页到最流行的网站开发.实现自己的博客网站.在云里雾里的云中搜索.大数 ...
- Centos 7 意外断电如何处理
拔U盘的时候,不小心碰到了主机上的开机键-- 还好默认的响应动作是睡眠-- 还不知道 CentOS 怎么样应对意外断电呢?!
- OSI模型第一层物理层
纪念我曾今热爱的数通(^o^). 物理层 一句话概述: OSI的第一层,它虽然处于最底层,却是整个开放系统的基础.物理层为设备之间的数据通信提供传输媒体及互连设备,为数据传输提供可靠的环境. 常见设备 ...
- sort vector - leetcode 新用法
179. Largest Number sort(num.begin(), num.end(), [](int a, int b){ return to_string(a)+to_string(b) ...
- TCP TIME_WAIT详解
转自:http://m.blog.chinaunix.net/uid-20384806-id-1954363.html TIME_WAIT状态 TCP要保证在所有可能的情况下使得所有的数据都能够正确被 ...
- mysql的数据类型与列属性
- hdu1031
#include <cstdio> #include <cstdlib> struct element{ int id; double sa; }e[10000]; int c ...
- 远程连接mysql数据库,1130问题
远程或使用非127.0.0.1和localhost地址连接时,出现代号为1130问题, ERROR 1130: Host 192.168.2.159 is not allowed to connect ...
- asp.net时间范围查询
1.首先要查询类表中的一个时间段,要明确我的数据库中只有一个时间字段,我们先将他拆分一下. if ($("#news_OpenTime").val() != "" ...