我有一个片段class FlipFragment : Fragment()
其中包括CircleShape。当我按下CircleShape时,我调用的方法用一些动画来改变它的资源。我需要这样做,当动画工作时 - onTouch被禁用。我怎么能这样做?
class FlipFragment : Fragment() {
private var layout = R.layout.view_flip
private lateinit var CircleShape: ImageView
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
var view: View = inflater!!.inflate(layout, container, false)
CircleShape = view.findViewById<ImageView>(R.id.fShapeView)
Log.i("TAG", CircleShape.isClickable.toString())
CircleShape.setOnClickLiastener { mechanics() }
return view
}
private fun mechanics() {
var mechanics = Mechanics(context, this.CircleShape, R.drawable.front_circle,
R.drawable.back_circle,
fCircleShapeView)
mechanics.animation() ///when this method is working - onTouch should be disable
mechanics.random()
}
答案 0 :(得分:0)
尝试将侦听器添加为AnimationListener。 示例:的
Mechanics.addAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
yourView.setEnabled(false);
}
@Override
public void onAnimationEnd(Animation animation) {
yourView.setEnabled(true);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
})