FancyBackground is a tiny Android library designed to animate a set of resource Drawables.

jopen 9年前發布 | 8K 次閱讀 Android開發 移動開發

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.

</tr>

</thead>

</tr>

</tbody> </table>

Achieving the above is easy:

FancyBackground.on(view)
               .set(R.drawable.fst, R.drawable.snd, R.drawable.trd)
               .inAnimation(R.anim.fade_in)
               .outAnimation(R.anim.fade_out)
               .interval(2500)
               .start(); 

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

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

Builder options

Before After
plain fancybg

</tr>

</thead>

</tr>

</tbody> </table>

FancyListener can receive four events:

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
  • sesese色