Android---播放gif
来源:互联网 发布:金数据怎么导出数据 编辑:程序博客网 时间:2024/05/20 01:33
在网上找了好多关于播放gif的资料。有一个是用流方式读入数据,强制刷新的,我试了,效果不怎么理想,有花纹。后来找到这篇文章Android开发第三方类库。决定采用android-gif-drawable方式,项目地址有demo源程序,可以参考下。
步骤:
1. 下载jar包:https://github.com/koral–/android-gif-drawable/
2. 将jar包拖放到libs目录。
3. 在JAVA文件中导入该包。
import com.ant.liao.GifView;
import com.ant.liao.GifView.GifImageType;
布局文件gif.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal"android:layout_width="fill_parent"android:layout_height="fill_parent"> <com.ant.liao.GifViewandroid:id="@+id/gif1" android:layout_height="wrap_content" android:layout_width="wrap_content"android:paddingRight="14px" android:enabled="false" /><TextView android:id="@+id/tsxt" android:layout_height="wrap_content" android:layout_width="wrap_content"android:paddingRight="4px" android:enabled="false"android:text="click the Angel" /> <com.ant.liao.GifViewandroid:id="@+id/gif2" android:layout_height="wrap_content" android:layout_width="wrap_content"android:paddingTop="4px" android:paddingLeft="14px" android:enabled="false" /></LinearLayout>
程序源码MainActivity.java:
package com.TestGif;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import com.ant.liao.GifView;import com.ant.liao.GifView.GifImageType; public class MainActivity extends Activity implements OnClickListener{private GifView gf1;private GifView gf2;private boolean f = true; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gif);gf1 = (GifView)findViewById(R.id.gif1);gf1.setGifImage(R.drawable.gif1);gf1.setOnClickListener(this);gf2 = (GifView)findViewById(R.id.gif2);gf2.setGifImageType(GifImageType.COVER);// 设置加载方式:先加载后显示、边加载边显示、只显示第一帧再显示 gf2.setShowDimension(300, 300);// 设置显示的大小,拉伸或者压缩
gf2.setGifImage(R.drawable.a); } public void onClick(View v) {if(f){gf1.showCover();f = false;}else{gf1.showAnimation();f = true;}} }
0 0
- android 实现gif播放
- Android播放gif动画
- Android 播放Gif 动画
- Android播放Gif动画
- Android 播放Gif 动画
- Android 播放Gif 动画
- Android播放GIF图片
- Android播放GIF动画
- android播放GIF动画
- Android 播放Gif 动画
- Android 播放Gif 动画
- android Gif图片播放
- Android 播放Gif 动画
- Android播放GIF动画
- Android 播放Gif 动画
- Android 播放Gif 动画
- Android播放GIF动画
- android播放gif图片
- ext2.0.2 设置textfield 显示隐藏
- Linux之NFS共享
- WPF“天狗食月”效果
- 从零开始学习cocoStudio(5)--骨骼动画使用方法
- HADOOP 分布式集群环境下第一个mapReduce程序—WordCount
- Android---播放gif
- 改代码——个人看法
- GroupingView 里groupTextTpl一些应用
- 科学家质疑当今商用量子计算机的性能
- 《STL源码剖析》学习--六大组件
- Aptana下Django1.6以后的项目模板结构改造
- Sublime Text2.0.2注册码
- mac终端命令大全介绍
- 2014 年推荐给 Web 设计师的 15 款 HTML&CSS 框架