Efectos de transición de diálogo

Actualmente estoy trabajando en los efectos de transición para mi diálogo. Por favor, consulte la siguiente imagen: Introduzca aquí la descripción de la imagen

La animación de entrada para mi diálogo debe ser de arriba a abajo. Mientras que la animación de salida debe ser de centro a superior. Estoy utilizando las siguientes animaciones XML, pero por desgracia, no funcionan.

Slide_down.xml

<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="1000"/> </set> 

Slide_up.xml

 <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:fromYDelta="0%p" android:toYDelta="50%p" android:duration="1000"/> 

EDIT: Este no es un Dialog habitual. Se trata de una activity aplicada con un Theme.Dialog en el Theme.Dialog AndroidManifest.xml

Si está creando el diálogo como una actividad, puede seguir este enfoque

Puede crear las clases de animación:

 public class DropDownToMiddleAnimation extends Animation { public int height, width; @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { // TODO Auto-generated method stub 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) { // TODO Auto-generated method stub 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); } 

Y:

 public class MiddleToTopAnimation extends Animation { public int height, width; @Override public void initialize(int width, int height, int parentWidth, int parentHeight) { // TODO Auto-generated method stub 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) { // TODO Auto-generated method stub super.applyTransformation(interpolatedTime, t); Matrix matrix = t.getMatrix(); camera.save(); camera.getMatrix(matrix); matrix.setTranslate(0, -((height/2) * interpolatedTime)) );//here is the change matrix.preTranslate(0, -height); camera.restore(); this.setAnimationListener(this); } 

Y utilizarlos con su diálogo

 LinearLayout ll = (LinearLayout) findViewById(R.id.parentLayout);//parent layout in the xml, which serves as the background in the custom dialog ll.startAnimation(new DropDownToMiddleAnimation());//use with launching of the dialog ll.startAnimation(new MiddleToTopAnimation());//use while dismissing the dialog/finishing the dialog activity 

Slide_down.xml

 <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="@android:integer/config_longAnimTime" android:fromYDelta="-50%p" android:toYDelta="0%p" /> 

Slide_up.xml

 <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android" android:duration="@android:integer/config_longAnimTime" android:fromYDelta="0%p" android:toYDelta="-100%p" /> 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.