• Stars
    star
    187
  • Rank 199,449 (Top 5 %)
  • Language
    Java
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

FAImageView is a Frame Animation ImageView for Android.

FAImageView

Android Arsenal

FAImageView is a Frame Animation ImageView for Android. You can set multiple frame images and start frame animation like UIImageView in iOS. You can animate multiple image like below!

Setup Gradle

dependencies {
	...
    compile 'kr.pe.burt.android.lib:faimageview:0.0.8'
}

Usages

Declare FAImageView widget in the layout xml file.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:orientation="vertical"
    tools:context=".MainActivity"
    >

    <kr.pe.burt.android.lib.faimageview.FAImageView
        android:id="@+id/faimageview1"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>


    <kr.pe.burt.android.lib.faimageview.FAImageView
        android:id="@+id/faimageview2"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>
</LinearLayout>

Set the options whatever you want

public class MainActivity extends AppCompatActivity {

    FAImageView faImageView1, faImageView2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        faImageView1 = (FAImageView)findViewById(R.id.faimageview1);
        faImageView1.setInterval(30);
        faImageView1.setLoop(true);
        faImageView1.addImageFrame(R.drawable.frame01);
        faImageView1.addImageFrame(R.drawable.frame02);
        faImageView1.addImageFrame(R.drawable.frame03);
        faImageView1.addImageFrame(R.drawable.frame04);
        faImageView1.addImageFrame(R.drawable.frame05);
        faImageView1.addImageFrame(R.drawable.frame06);
        faImageView1.addImageFrame(R.drawable.frame07);
        faImageView1.addImageFrame(R.drawable.frame08);
        faImageView1.addImageFrame(R.drawable.frame09);
        faImageView1.addImageFrame(R.drawable.frame10);


        faImageView2 = (FAImageView)findViewById(R.id.faimageview2);
        faImageView2.setInterval(100);
        faImageView2.setLoop(true);
        faImageView2.addImageFrame(R.drawable.frame01);
        faImageView2.addImageFrame(R.drawable.frame02);
        faImageView2.addImageFrame(R.drawable.frame03);
        faImageView2.addImageFrame(R.drawable.frame04);
        faImageView2.addImageFrame(R.drawable.frame05);
        faImageView2.addImageFrame(R.drawable.frame06);
        faImageView2.addImageFrame(R.drawable.frame07);
        faImageView2.addImageFrame(R.drawable.frame08);
        faImageView2.addImageFrame(R.drawable.frame09);
        faImageView2.addImageFrame(R.drawable.frame10);

    }

    @Override
    protected void onResume() {
        super.onResume();
        faImageView1.startAnimation();
        faImageView2.startAnimation();
    }

    @Override
    protected void onPause() {
        super.onPause();
        faImageView1.stopAnimation();
        faImageView2.stopAnimation();
    }
}

Callbacks

FAImageView provides some listeners for animation event.

  • for listening to animation start.
  • OnStartAnimationListener
  • for listening to animation completion.
  • OnFinishAnimationListener
  • for listening to animation frame change event
  • OnFrameChangedListener
faImageView.setOnStartAnimationListener(new FAImageView.OnStartAnimationListener() {
    @Override
    public void onStartAnimation() {
        Log.v("FAImageView", "Animation started");
    }
});

faImageView.setOnFinishAnimationListener(new FAImageView.OnFinishAnimationListener() {
    @Override
    public void onFinishAnimation(boolean isLoopAnimation) {
        if(isLoopAnimation) {
            Log.v("FAImageView", "finished an animation cycle.");
        } else {
            Log.v("FAImageView", "Animation is completed");
        }
    }
});

faImageView.setOnFrameChangedListener(new FAImageView.OnFrameChangedListener() {
    @Override
    public void onFrameChanged(int index) {
        Log.v("FAImageView", String.format("frameIndex : %d", index));
    }
});

APIs

  • setInterval(int milli)
  • set frame interval for animation in milli seconds
  • addImageFrame(int resId)
  • addImageFrame(Drawable drawable)
  • addImageFrame(Bitmap bitmap)
  • add an Image Frame
  • setLoop(boolean loop)
  • If you want to animate infinitely set true or false. Default value is false.
  • setRestoreFirstFrameWhenFinishAnimation(boolean restore)
  • If you want to restore the first frame when animation is finished, set true or false.
  • setAnimationRepeatCount(int animationRepeatCount)
  • Only If your animation is not infinity, this value is valuable.
  • startAnimation()
  • start animation
  • stopAnimation
  • stop animation
  • isAnimating
  • check it's now animating
  • reset
  • clear all resources and stop animation.

MIT License

The MIT License

Copyright Β© 2015 Sungcheol Kim, http://github.com/skyfe79/FAImageView

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

SwiftImageProcessing

This project demonstrates how to do pixel operations in swift.
Swift
523
star
2

AndroidGradientImageView

AndroidGradientImageView is a simple imageview which overlays gradient on its content.
Java
218
star
3

LearningOpenGLES2

Learning OpenGL ES 2 in Swift
Swift
201
star
4

LearningOpenGLES2-Android

Learning OpenGL ES 2 in Java for Android
Java
185
star
5

AndroidChannel

AndroidChannel is helper library for thread communication between mainthread and workerthread
Java
81
star
6

AndroidOperationQueue

AndroidOperationQueue is a tiny serial operation queue for Android.
Java
50
star
7

AnimateGradientView

AnimateGradientView is android library to make gradient flow or rotate infinitely
Java
47
star
8

FragmentNavigationController

FragmentNavigationController is a convenient utility library to navigate fragments on Android.
Java
35
star
9

AndroidGLKit

AndroidGLKit provides OpenGL ES 2.0 boilerplate codes for Android.
Java
22
star
10

HashGirl

HashGirl is a simple library to make a linkable string for Android.
Java
20
star
11

RxGitSearch

RxGitSearch is iOS demo app searching github repositories. It uses some Rx techniques to achieve flexible, auto ui update, no dependencies and others.
Swift
19
star
12

KeyboardEditText

KeyboardEditText provides keyboard's shown and hidden event listener for you.
Java
18
star
13

hugo-with-github-issues

hugo-with-github-issues
JavaScript
10
star
14

SGL

Software 3D Graphics Rendering Library
C++
9
star
15

UsingSwiftAndCpp

It demonstrated how to use swift and c++ on same project space.
Swift
6
star
16

VideoSplashView

VideoSplashView is a simple video view for making Splash Scene that contains video.
Swift
5
star
17

GLUT-Tutorial

glut tutorial
C++
4
star
18

Awesome

My Awesome from the starred repos πŸ˜‹
4
star
19

RxPlayground

Learn RxSwift
Swift
3
star
20

OpenGL-ES-Tutorials

Objective-C
3
star
21

OpenGLTutorial

OpenGL Tutorial
C++
3
star
22

SwiftTypeEraserWrapper

TypeEraserWrapper 에 λŒ€ν•œ λΈ”λ‘œκ·Έ κΈ€ μ˜ˆμ œμž…λ‹ˆλ‹€.
Swift
3
star
23

AndroidCameraInfo

print camera infos to textview
Java
2
star
24

AVFoundation

about AVFoundation
Objective-C
2
star
25

github-actions-starter-kit

Github Actions starter kit to create actions in javascript
JavaScript
2
star
26

LearningCoreGraphics

Learning Core Graphics in Swift
Swift
1
star
27

AndroidActivity

AndroidActivity provides lifecycle callback methods from the aspect of view. If you use these callback methods, you don't have to use ViewTreeObserver.
Java
1
star
28

HelloFFmpeg

FFmpeg & SDL with XCode
C
1
star
29

blog.contents

My Blog Contents
HTML
1
star
30

TIL

Today I learned
Objective-C
1
star
31

AndroidKommon

Collection of Android utility extentions in Kotlin
Java
1
star
32

iOSToolkit

iOS κ°œλ°œμ— ν•„μš”ν•œ μœ ν‹Έλ¦¬ν‹° 및 ν™•μž₯을 λͺ¨μ•„ λ†“λŠ”λ‹€
Objective-C
1
star
33

awesome-readme-generator

Generate Awesome Readme.md from your Github starred repos ;)
JavaScript
1
star