I have LayoutParams transition with addRule().
My view changes position but duration is instant.
I work on API 15 so I cant use beginDelayedTransition().
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final RelativeLayout.LayoutParams positionRules = new RelativeLayout.LayoutParams(layoutFalse.getWidth(), layoutFalse.getHeight());
positionRules.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
positionRules.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
layoutFalse.requestLayout();
layoutFalse.setLayoutParams(positionRules);
}
};
a.setDuration(3000);
layoutFalse.startAnimation(a);
Inside this block you do animate nothing. You just say:
Let this object be in each frame with the contrains I want. No more.
So, I think, If you want to animate something you have to use interpolatedTime like this: To setup position of view inside RelativeLayout without animation:
public void setTopLeftCornerF(float leftMargin, float topMargin) {
if (this.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)this.getLayoutParams();
params.width = (int)_width;//w();
params.height = (int)_height;//h();
params.setMargins((int)leftMargin, (int)topMargin, (int)-leftMargin, (int)-topMargin);
this.setLayoutParams(params);
}
}
to use animation somewhere:
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
// TODO Auto-generated method stub
super.applyTransformation(interpolatedTime, t);
float posX = (float) (mFromX + ((mToX - mFromX) * interpolatedTime));
float posY = (float) (mFromY + ((mToY - mFromY) * interpolatedTime));
t.getMatrix().setTranslate(posX,posY);
}
Or use TranslateAnimation as described here
applyTransformation() gets called for each animation frame and the transformation should use the interpolatedTime param to calculate transformations for that frame. Your applyTransformation() applies the changes unconditionally so the result is the same for all frames.
If you just want to change the layout after a specified time, use layoutFalse.postDelayed() to post a Runnable that applies the changes after a delay.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With