I'd try to move with Animation a LinearLayout with some stuff inside
when clicking on it. Apply the Animation is pretty simple. I've done
something like this.
//ANIMATION
public static Animation animationTest(int duration) {
Animation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
0.0f, Animation.RELATIVE_TO_SELF, 1.0f);
anim.setDuration(duration);
Interpolator inter = new DecelerateInterpolator(0.4f);
anim.setInterpolator(inter);
anim.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
changeLayoutPosition(layout);
}
});
return anim;
}
Than I want to be able to click again the layout which is moved to an
other position, so as I read in many topic, I have to change the
layout, so I've done...
public static void changeLayoutPosition(LinearLayout layout) {
LinearLayout.LayoutParams params = new
LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 100);
params.topMargin = layout.getHeight();
layout.setLayoutParams(params);
layout.requestLayout();
}
It works! But at the end of the animation, probably when requestLayout
is called, the LinearLayout produces a sort of artefact, as if it was
drawn once again. Is it possible? Why?
I expected to see the animation that works normally and to change the
layout position in background without to be draw again... Am I wrong
something? Is there some tricks to avoid this kind of flickering?
Thanks in advance
Paolo
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment