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
方法名 | 描述 |
---|---|
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可以接收4个事件:
-
onStarted 当FancyBackground开始时
-
onNew 当设置一张新的图片之时
-
onLoopDone 如果循环设置成false,而第一个循环已经完成。
-
onStopped 当ancyBackground 结束时。
FancyCache允许你创建自己的bitmap缓存。默认是FancyLruCache,在内存满时腾出最近使用的bitmap。可以使用null来避免缓存。
已下载
0