实战系列
话不多说,Android实战系列集合都已经系统分类好,由于文章篇幅问题没法过多展示
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
android:layout_width=“wrap_content”
android:paddingTop=“4px”
android:paddingLeft=“14px”
android:enabled=“false” />
3- 在代码中配置常用属性:
// 从xml中得到GifView的句柄
gf1 = (GifView) findViewById(R.id.gif1);
// 设置Gif图片源
gf1.setGifImage(R.drawable.gif1);
// 添加监听器
gf1.setOnClickListener(this);
// 设置显示的大小,拉伸或者压缩
gf1.setShowDimension(300, 300);
// 设置加载方式:先加载后显示、边加载边显示、只显示第一帧再显示
gf1.setGifImageType(GifImageType.COVER);
GifView的Jar包共有四个类:
GifAction.java:
观察者类,监视GIF是否加载成功
package com.ant.liao;
public interface GifAction {
/**
*gif解码观察者
-
@hide
-
@param parseStatus 解码是否成功,成功会为true
-
@param frameIndex 当前解码的第几帧,当全部解码成功后,这里为-1
*/
public void parseOk(boolean parseStatus,int frameIndex);
}
GifFrame.java
里面三个成员:当前图片、延时、下张Frame的链接。
package com.ant.liao;
import android.graphics.Bitmap;
public class GifFrame {
/**
-
构造函数
-
@param im 图片
-
@param del 延时
*/
public GifFrame(Bitmap im, int del) {
image = im;
delay = del;
}
public GifFrame(String name,int del){
imageName = name;
delay = del;
}
/*图片/
public Bitmap image;
/*延时/
public int delay;
/*当图片存成文件时的文件名/
public String imageName = null;
/*下一帧/
public GifFrame nextFrame = null;
}
GifDecoder.java
解码线程类
http://code.google.com/p/gifview/source/browse/trunk/src/com/ant/liao/GifDecoder.java
GifView.java
主类,包括常用方法,如GifView构造方法、设置图片源、延迟、绘制等。
http://code.google.com/p/gifview/source/browse/trunk/src/com/ant/liao/GifView.java
android-gif-drawable
android-gif-drawable
Views and Drawable for animated GIFs in Android.
项目地址:https://github.com/koral–/android-gif-drawable
Overview
Bundled GIFLib via JNI is used to render frames. This way should be more efficient thanWebView or Movie classes.
Animation starts automatically and run only if View with attached GifDrawable is visible.
Download
Latest release downloads
Setup
Gradle (Android Studio)
Insert the following dependency to build.gradle file of your project.
1.
dependencies {
2.
compile
'pl.droidsonroids.gif:android-gif-drawable:1.0.+'
3.
}
Note that Maven central repository should be defined eg. in top-level build.gradle like this:
01.
buildscript {
02.
repositories {
03.
mavenCentral()
04.
}
05.
}
06.
allprojects {
07.
repositories {
08.
mavenCentral()
09.
}
10.
}
Maven dependency
SDK with API level 19 is needed. If you don’t have it in your local repository, downloadmaven-android-sdk-deployer and install SDK level 19:mvn install -P 4.4 (from maven-android-sdk-deployer directory). Then add dependency inpom.xml of your project:
1.
<dependency>
2.
<groupId>pl.droidsonroids.gif</groupId>
3.
<artifactId>android-gif-drawable</artifactId>
4.
<version>insert latest version here</version>
5.
<type>aar</type>
6.
</dependency>
Requirements
Android 1.6+ (API level 4+)
Building from source
Android NDK needed to compile native sources
Usage
From XML
The simplest way is to use GifImageView (or GifImageButton) like a normalImageView:
1.
<pl.droidsonroids.gif.GifImageView
2.
android:layout_width=``"match_parent"
3.
android:layout_height=``"match_parent"
4.
android:src=``"@drawable/src_anim"
5.
android:background=``"@drawable/bg_anim"
6.
/>
If drawables declared by android:src and/or android:background are GIF files then they will be automatically recognized asGifDrawables and animated. If given drawable is not a GIF then mentioned Views work like plainImageView and ImageButton.
GifTextView allows you to use GIFs as compound drawables and background.
1.
<pl.droidsonroids.gif.GifTextView
2.
android:layout_width=``"match_parent"
3.
android:layout_height=``"match_parent"
4.
android:drawableTop=``"@drawable/left_anim"
5.
android:drawableStart=``"@drawable/left_anim"
6.
android:background=``"@drawable/bg_anim"
7.
/>
From Java code
GifImageView, GifImageButton and GifTextView have also hooks for setters implemented. So animated GIFs can be set by callingsetImageResource(int resId) and setBackgroundResource(int resId)
GifDrawable can be constructed directly from various sources:
01.
//asset file
02.
GifDrawable gifFromAssets =
new
GifDrawable( getAssets(),
"anim.gif"
);
03.
04.
//resource (drawable or raw)
05.
GifDrawable gifFromResource =
new
GifDrawable( getResources(), R.drawable.anim );
文末
好了,今天的分享就到这里,如果你对在面试中遇到的问题,或者刚毕业及工作几年迷茫不知道该如何准备面试并突破现状提升自己,对于自己的未来还不够了解不知道给如何规划,可以来看看同行们都是如何突破现状,怎么学习的,来吸收他们的面试以及工作经验完善自己的之后的面试计划及职业规划。
这里放上一部分我工作以来以及参与过的大大小小的面试收集总结出来的一套进阶学习的视频及面试专题资料包,主要还是希望大家在如今大环境不好的情况下面试能够顺利一点,希望可以帮助到大家
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
到的问题,或者刚毕业及工作几年迷茫不知道该如何准备面试并突破现状提升自己,对于自己的未来还不够了解不知道给如何规划,可以来看看同行们都是如何突破现状,怎么学习的,来吸收他们的面试以及工作经验完善自己的之后的面试计划及职业规划。
这里放上一部分我工作以来以及参与过的大大小小的面试收集总结出来的一套进阶学习的视频及面试专题资料包,主要还是希望大家在如今大环境不好的情况下面试能够顺利一点,希望可以帮助到大家
[外链图片转存中…(img-iWIJewuE-1715671861009)]
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!