문제

I have 2 views with the same animation, during this animation these views should change your Z Orders for example The View A is over the View B during the animation I change this order, I'm getting this with viewA or viewB .bringToFront(); but the but the update is not immediate and I need this Z order changed at an exact point.

Thanks.

도움이 되었습니까?

해결책

I solve this as follows:

first in animation you set the custom interpolator, your class needs implements the ICustomInterpolator

animation.setInterpolator(new CustomInterpolator(this));
a.startAnimation(animation);
b.startAnimation(animation);

after

public void currentProgress(float p, float time) {
    if(time == yourTime){
        a.bringToFront();
        a.invalidate();
        b.invalidate();
        a.requestLayout();
        b.requestLayout();
    }
}

the currentProgress is a Inteface method of a custom interpolator:

public interface ICustomInterpolator {
    public void currentProgress(float p, float time);
}

in customInterpolator:

public class CustomInterpolator extends
    AccelerateDecelerateInterpolator {

    private ICustomInterpolator delegate;

    public <T extends ICustomInterpolator> CustomInterpolator(T delegate) {
        super();
        this.delegate = delegate;
    }

    @Override
    public float getInterpolation(float input) {
        delegate.currentProgress(input);
        return super.getInterpolation(input);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top