项目作者: tslamic

项目描述 :
FancyBackground is a tiny Android library designed to animate a set of resource Drawables.
高级语言: Java
项目地址: git://github.com/tslamic/FancyBackground.git
创建时间: 2015-02-02T08:25:30Z
项目社区:https://github.com/tslamic/FancyBackground

开源协议:

下载


FancyBackground

FancyBackground is a tiny Android library designed to animate a set of resource Drawables. It ensures the drawables are subsampled and cached, if necessary, with heavy lifting done in the background.

Before After
plain fancybg

Achieving the above is easy:

  1. FancyBackground.on(view)
  2. .set(R.drawable.fst, R.drawable.snd, R.drawable.trd)
  3. .inAnimation(R.anim.fade_in)
  4. .outAnimation(R.anim.fade_out)
  5. .interval(2500)
  6. .start();

Don’t forget to add the following in your build.gradle:

  1. dependencies {
  2. compile 'com.github.tslamic.fancybackground:library:1.0'
  3. }

Builder options

Method name Description
set sets the Drawable resources we wish to show/animate
inAnimation specifies the animation used to animate a View entering the screen.
outAnimation specifies the animation used to animate a View exiting the screen.
loop continuously loop through the Drawables or stop after the first cycle is complete.
interval the millisecond interval a Drawable instance will be displayed for.
scale determines how the Drawables should be resized or moved to match the size of the view we’re animating on.
listener receives the FancyBackground events (described below)
cache caches loaded bitmaps so we don’t have to do it again

FancyListener can receive four events:

  • onStarted when the FancyBackground is started
  • onNew when a new image is set
  • onLoopDone if looping is set to false and the first cycle is complete
  • onStopped when the FancyBackground stops.

FancyCache enables you to create your own bitmap cache. FancyLruCache is the default, targeting ~25% of the available heap and evicting the least recently used bitmap if over capacity. Use null to avoid caching.

An example?

See app for a hands-on example.

How to get it?

Gradle

  1. dependencies {
  2. compile 'com.github.tslamic.fancybackground:library:1.0'
  3. }

Maven

  1. <dependency>
  2. <groupId>com.github.tslamic.fancybackground</groupId>
  3. <artifactId>library</artifactId>
  4. <version>1.0</version>
  5. </dependency>

or download the aar by clicking here.

License

  1. The MIT License (MIT)
  2. Copyright (c) 2015 Tadej Slamic
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.