我是菜鸟和菜鸟,但是当按下带动画的图像按钮时是否可以添加另一张图像?
答案 0 :(得分:2)
是的,有可能。使用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*/);
}
});