OnTouch
一个ImageView
我开始淡出动画:
myImageView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
v.startAnimation(fadeInAnimation);
Run Code Online (Sandbox Code Playgroud)
我知道需要一个动画监听器才能找到动画完成的时间,但是如何附加它以便我可以获得动画刚刚完成的视图...我想在动画后设置视图的可见性已经完成了.
谢谢
小智 109
我想你需要这个.
fadeInAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
Run Code Online (Sandbox Code Playgroud)
jon*_*nas 20
如果您只需要一个结束动作就足够了 .withEndAction(Runnable)
fadeInAnimation.withEndAction(new Runnable() {
@Override
public void run() {
... do stuff
}
})
Run Code Online (Sandbox Code Playgroud)
如果有人需要以下解决方案kotlin
:
fadeInAnimation.setAnimationListener(object: Animation.AnimationListener {
override fun onAnimationRepeat(animation: Animation?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onAnimationEnd(animation: Animation?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onAnimationStart(animation: Animation?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
})
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
53132 次 |
最近记录: |