【发布时间】:2015-12-24 00:43:21
【问题描述】:
点击复选框时,会触发默认的 Android Material Design 动画(从空白到“V”标记,从“V”标记到空白)。
我想确定动画何时结束。
根据文档,这应该可以通过以下两种方式之一实现 -
当复选框被选中或未选中时(
setOnCheckedChangeListener()),获取当前动画对象(getAnimation())并在其上注册一个监听器(setAnimationListener())。不幸的是,这不起作用 - Animation 对象此时为null。子类化 Checkbox 对象并实现其
onAnimationEnd()方法。不幸的是,这不起作用 - 该方法永远不会被调用。
我错过了什么?确定这种默认动画何时结束的好方法是什么?我假设相关事件可以在活动的其他视图上注册,但我不知道是哪个。
这是第一种方法的相关代码sn-p(动画总是null)-
CheckBox checkBox = (CheckBox)findViewById(R.id.checkbox1);
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
Animation animation = compoundButton.getAnimation();
Log.d("Checkbox", "Animation is " + animation);
}
});
【问题讨论】:
标签: android animation checkbox material-design