I have 2 ImageView
s that I translate from the top of the screen to the bottom. these views are infalted from xml and the animation is added from java code. The animation works perfectly, but the onClickListener
I added in java code doesn't seem to work. I used fillAfter
attribute of the animation to make the iamges stay at their arrival after the translation, but THESE images aren't clickable anymore... However, their position before translation remains clickable...
I can't see the logic of this. Could anyone give me some piece of advice about that?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This is because Animations affects only the drawing of widget. However, The real Location is not affected -It is still in the previous one-.
To overcome this problem, you need to update the layout parameters of the ImageView manually by installing an animation listener as follows:
Animation.setAnimationListener(new AnimationListener() {
public void onAnimationStart(Animation arg0) {
}
public void onAnimationRepeat(Animation arg0) {
//TODO Auto-generated method stub
}
public void onAnimationEnd(Animation arg0) {
android.widget.LinearLayout.LayoutParams params = new LayoutParams(
android.widget.LinearLayout.LayoutParams.FILL_PARENT,
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT);
params.topMargin = addLocationButton.getTop()-100;
ImageView.setLayoutParams(params);
}
});