FancyBackground

介绍:

FancyBackground是一个可以设置一组Drawable动画背景资源的库。图片可以压缩和缓存。

运行效果:

使用说明:

要达到图中的效果很简单:

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();

别忘了在build.gradle中添加如下代码:

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

Builder options

方法名描述
setsets the Drawable resources we wish to show/animate
inAnimationspecifies the animation used to animate a View entering the screen.
outAnimationspecifies the animation used to animate a View exiting the screen.
loopcontinuously loop through the Drawables or stop after the first cycle is complete.
intervalthe millisecond interval a Drawable instance will be displayed for.
scaledetermines how the Drawables should be resized or moved to match the size of the view we're animating on.
listenerreceives the FancyBackground events (described below)
cachecaches loaded bitmaps so we don't have to do it again

FancyListener可以接收4个事件:

  • onStarted   当FancyBackground开始时

  • onNew 当设置一张新的图片之时

  • onLoopDone 如果循环设置成false,而第一个循环已经完成。

  • onStopped 当ancyBackground 结束时。

FancyCache允许你创建自己的bitmap缓存。默认是FancyLruCache,在内存满时腾出最近使用的bitmap。可以使用null来避免缓存。

已下载
0