在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):florent37/KotlinPleaseAnimate开源软件地址(OpenSource Url):https://github.com/florent37/KotlinPleaseAnimate开源编程语言(OpenSource Language):Kotlin 98.5%开源软件介绍(OpenSource Introduction):Kotlin Please Animate
A Kotlin way to declare and run beautiful animations ! Please be gentle with Kotlin :) please {
animate(avatar) toBe {
bottomOfItsParent(marginDp = 36f)
leftOfItsParent(marginDp = 16f)
width(40, keepRatio = true, toDp = true)
}
}.start() Downloadimplementation 'com.github.florent37:kotlinpleaseanimate:1.0.2' This code describe the video above please(duration = 1500L) {
animate(avatar) toBe {
bottomOfItsParent(marginDp = 36f)
leftOfItsParent(marginDp = 16f)
visible()
width(40, keepRatio = true, toDp = true)
}
animate(name) toBe {
rightOf(avatar, marginDp = 16f)
sameCenterVerticalAs(avatar)
textColor(Color.WHITE)
}
animate(subname) toBe {
rightOf(name, marginDp = 5f)
sameCenterVerticalAs(name)
textColor(Color.WHITE)
}
animate(revert) toBe {
rightOfItsParent(marginDp = 4f)
bottomOfItsParent(marginDp = 12f)
backgroundAlpha(0f)
}
animate(start) toBe {
aboveOf(revert, marginDp = 4f)
rightOfItsParent(marginDp = 4f)
backgroundAlpha(0f)
}
animate(bottomLayout) toBe {
originalPosition()
}
animate(content) toBe {
originalPosition()
visible()
}
}.start() Follow scrollUse Exemple with a scrollview val animation = please {
animate(avatar) toBe {
topOfItsParent(marginDp = 20f)
leftOfItsParent(marginDp = 20f)
scale(0.5f, 0.5f)
}
animate(username) toBe {
rightOf(avatar, marginDp = 16f)
sameCenterVerticalAs(avatar)
alpha(0.5f)
}
animate(revert) toBe {
rightOfItsParent(marginDp = 20f)
sameCenterVerticalAs(avatar)
}
animate(background) toBe {
height(h, horizontalGravity = Gravity.LEFT, verticalGravity = Gravity.TOP)
}
}
scrollview.setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY ->
val percent = scrollY * 1f / v.maxScrollAmount
animation.setPercent(percent)
}) Chain animationsJust ask the kotlin's animation if he wants to execute another animation after, using
Apply directlyIf you want your animation to be applied directly, be bossy with kotlin and force it to apply it using please {
animate(view) toBe {
outOfScreen(Gravity.BOTTOM)
}
}.now(); ResetUse animation.reset(): List of expectations
CreditsAuthor: Florent Champigny Blog : http://www.tutos-android-france.com/ Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/ Forked from ExpectAnim: https://github.com/florent37/ExpectAnim License
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论