View show 从下往上展示
fun show() {
val anim = AnimationUtils.loadAnimation(context, R.anim.slide_in_down)
anim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
}
override fun onAnimationRepeat(animation: Animation?) {
}
})
this.startAnimation(anim)
this.visible()
}
slide_in_down 文件实现:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="350"/>
<!--<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="350" />-->
</set>
View 从上往下退出:
fun dismiss() {
val anim = AnimationUtils.loadAnimation(context, R.anim.slide_out_down)
anim.setAnimationListener(object : Animation.AnimationListener {
override fun onAnimationStart(animation: Animation?) {
}
override fun onAnimationEnd(animation: Animation?) {
this@SelfView.gone()
}
override fun onAnimationRepeat(animation: Animation?) {
}
})
this.startAnimation(anim)
}
slide_out_down 文件实现:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="350"/>
<!--<alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:duration="350" />-->
</set>
网友评论