if you create a dialogue as an action, you can follow this approach
You can create animation classes:
public class DropDownToMiddleAnimation extends Animation {
public int height, width;
@Override
public void initialize(int width, int height, int parentWidth,
int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
this.width = width;
this.height = height;
setDuration(500);
setFillAfter(true);
setInterpolator(new LinearInterpolator());
}
Camera camera = new Camera();
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
Matrix matrix = t.getMatrix();
camera.save();
camera.getMatrix(matrix);
matrix.setTranslate(0, ((height/2) * interpolatedTime)) );
matrix.preTranslate(0, -height);
camera.restore();
this.setAnimationListener(this);
}
and:
public class MiddleToTopAnimation extends Animation {
public int height, width;
@Override
public void initialize(int width, int height, int parentWidth,
int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
this.width = width;
this.height = height;
setDuration(500);
setFillAfter(true);
setInterpolator(new LinearInterpolator());
}
Camera camera = new Camera();
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
super.applyTransformation(interpolatedTime, t);
Matrix matrix = t.getMatrix();
camera.save();
camera.getMatrix(matrix);
matrix.setTranslate(0, -((height/2) * interpolatedTime)) );
matrix.preTranslate(0, -height);
camera.restore();
this.setAnimationListener(this);
}
and use them using the dialog
LinearLayout ll = (LinearLayout) findViewById(R.id.parentLayout);
ll.startAnimation(new DropDownToMiddleAnimation());
ll.startAnimation(new MiddleToTopAnimation());
source
share