FAImageView


Source link: https://github.com/skyfe79/FAImageView

FAImageView

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.

Resources

Persistent SearchView Library in Material Design.

AudioPlayerView is an Android view that loads audio from an url and have basic playback tools.

DroidKaigi 2016 official Android app.

A chat heads library for android.

A full featured Color picker Library for Android! Just like the one in Photoshop!

SeatBookingRecyclerView is a custom RecyclerView using GridLayoutManager that can be used as a layout to book bus, flight tickets.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes