最近的项目需要在界面显示Gif动图,查找网络资料,总结了一下,分享一下,

一个GifView的gif图加载库以有效地显示GIF,

您可以启动,暂停和停止gifView

在app 的 build.gradle 中

implementation 'com.github.Cutta:GifView:1.4'

效果图:

1:布局直接显示

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<com.cunoraz.gifview.library.GifView
android:id="@+id/gif1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
custom:gif="@mipmap/gif1" /> <com.cunoraz.gifview.library.GifView
android:id="@+id/gif3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
/> </LinearLayout>

2:代码

/***
* 属性
*
* gifView1.setGifResource(R.mipmap.gif_start_stop);
* gifView1.play();
* gifView1.pause();
* gifView1.setGifResource(R.mipmap.gif5);
* gifView1.getGifResource();
* gifView1.setMovieTime(time);
* gifView1.getMovie();
*/ private void show(){
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { if (gifView1.isPlaying())
gifView1.pause();
}
});
btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { if (gifView1.isPaused())
gifView1.play();
}
});
}

代码文档:https://github.com/Cutta/GifView

最新文章

  1. Web服务器控件之button
  2. 深入理解http/https协议
  3. 学习 Linux,101: Linux 命令行
  4. ssh git免密码提交代码
  5. JFreeChart 使用一 饼图之高级特性
  6. 《深入PHP与jQuery开发》读书笔记——Chapter1
  7. 101个MySQL 的调节和优化的提示
  8. java的回忆录
  9. Controller中利用RedirectToRoute重定向的问题
  10. PHP学习笔记(八)
  11. 如何解决设置Session保存在StateServer后引起WebService/WebMethod无法异步获取Session
  12. Codeforces 715A &amp; 716C Plus and Square Root【数学规律】 (Codeforces Round #372 (Div. 2))
  13. nginx 配置以及常用命令
  14. dedecms likearticle 调用附加表的字段调用方式
  15. 点击显示子菜单,离开隐藏子菜单(onmouseout下包含a标签的js解决方法)
  16. [模板][Luogu3387] 缩点 - Tarjan, 拓扑+DP
  17. Java学习之--List和ArrayList
  18. Android面试准备20190422
  19. JavaScript事件属性event.target
  20. 得到ImageView中drawable显示的区域的计算方法

热门文章

  1. python判断目录或者文件
  2. springboot学习笔记(一)
  3. Hibernate的关联关系映射
  4. [TypeScript ] Using the Null Coalescing operator with TypeScript 3.7
  5. php自定义函数之回调函数
  6. 2019/7/18 --1.&lt;%@ include file=&quot;&quot;%&gt;与&lt;jsp:include page=&quot;&quot;/&gt;两种方式的作用
  7. PHP安装之configure的配置参数
  8. Makefile(二)
  9. 数据结构实验之查找六:顺序查找(SDUT 3378)
  10. avalon在公共页面里面写的功能,怎么让某些页面不引用到这个方法和html?