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?
TranslateAnimated ImageView not clickable after animation [Android]
Ok, found my answer here : #2126194 now I just need to set its params properly to get its position right... –
Rancorous
However, this does not seem to be compatible with setFillAfter. I add to remove it to get it to work. –
Rancorous
I had this problem, and I solved it after some research. [Here you can find an answer][1] [1]: #18333769 –
Beckner
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);
}
});
No good, because after the animation in onAnimationEnd, when the image get the position from "setLayoutParams(params);" then I see a flicker. I add that is difficult to set the topMargin from the percentage of the property toYDelta –
Patmos
To remove the flicker you can use animation.reset(); <my view>.clearAnimation(); –
Advertent
© 2022 - 2024 — McMap. All rights reserved.