我是菜鸟和菜鸟,但是当按下带有动画的图像按钮时,是否可以添加另一个图像?
问问题
878 次
1 回答
2
Yes, it is possible. Use the TransitionDrawable
, Luke!
mYourImageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Drawable[] layers = new Drawable[2];
layers[0] = getResources().getDrawable(R.drawable.image1);
layers[1] = getResources().getDrawable(R.drawable.image2);
TransitionDrawable transition = new TransitionDrawable(layers);
transition.setCrossFadeEnabled(true);
mYourImageButton.setImageDrawable(transition);
transition.startTransition(500 /*animation duration*/);
}
});
于 2014-05-09T14:27:19.637 回答