reveal动画效果的库:EasyReveal
从名字就知道,这是一个提供reveal
动画效果的库,它的厉害之处在于可以提供不同尺寸、不同形状的reveal动画,并且还可以在定义它在屏幕任意位置开始和结束动画。
4.1 如何使用?
在build.gradle
中添加如下依赖:
dependencies {
...
implementation 'com.github.Chrisvin:EasyReveal:1.2'
}
然后,xml中,需要添加显示或者隐藏动画的View应该包裹在EasyRevealLinearLayout
中:
也可以在代码中添加:
val revealLayout = EasyRevealLinearLayout(this)
// Set the ClipPathProvider that is used to clip the view for reveal animation
revealLayout.clipPathProvider = StarClipPathProvider(numberOfPoints = 6)
// Set the duration taken for reveal animation
revealLayout.revealAnimationDuration = 1500
// Set the duration taken for hide animation
revealLayout.hideAnimationDuration = 2000
// Set listener to get updates during reveal/hide animation
revealLayout.onUpdateListener = object: RevealLayout.OnUpdateListener {
override fun onUpdate(percent: Float) {
Toast.makeText(this@MainActivity, "Revealed percent: $percent", Toast.LENGTH_SHORT).show()
}
}
// Start reveal animation
revealLayout.reveal()
// Start hide animation
revealLayout.hide()
4.2效果图
Emotion Dialog | Drake Dialog | Emoji Dialog |
---|---|---|
更多详细使用信息请看Github: https://github.com/Chrisvin/EasyReveal