title: Dialog box after animation going to top
body: <p>I am making a custom dialog box which will pop up using animation from bottom to centre. everything is fine but after the animation dialog box is going to the top of the screen. I want it to be in centre only. Here is my code . </p>
  
  <pre><code> public class CustomDialogClass extends Dialog implements
      android.view.View.OnClickListener {
  
      public Activity c;
      public Dialog d;
      public Button yes, no;
      private Animation mAnimationBottomCentre;
  
      public CustomDialogClass(Activity a) {
      super(a,R.style.DialogAnimation);
      // TODO Auto-generated constructor stub
      this.c = a;
      }
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      setContentView(R.layout.dialog_view);
  
  //  LinearLayout ll = (LinearLayout) findViewById(R.id.mainlayout);
  //  mAnimationBottomCentre = AnimationUtils.loadAnimation(c, R.anim.slide_in_left);
  //  ll.startAnimation(mAnimationBottomCentre);
      yes = (Button) findViewById(R.id.btn_yes);
      no = (Button) findViewById(R.id.btn_no);
      yes.setOnClickListener(this);
      no.setOnClickListener(this);
  
      }
  
      @Override
      public void onClick(View v) {
      switch (v.getId()) {
      case R.id.btn_yes:
          c.finish();
          break;
      case R.id.btn_no:
          dismiss();
          break;
      default:
          break;
      }
      dismiss();
      }
  }
  </code></pre>
  
  <p>I am calling dialog box from my activity like this:</p>
  
  <pre><code> public void Show_Dialog(View v) {
  CustomDialogClass cdd = new CustomDialogClass(MainActivity.this);
  cdd.getWindow().getAttributes().windowAnimations = com.example.chintan.khetiya.android.custom_dialog.R.style.DialogAnimation;
  cdd.getWindow().setGravity(Gravity.CENTER);
  cdd.show();
  }
  </code></pre>
  
  <p>this is my anim file </p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;set xmlns:android="http://schemas.android.com/apk/res/android"
      android:fillAfter="true"
      android:interpolator="@android:anim/decelerate_interpolator" &gt;
    &lt;translate
          android:duration="2000"
          android:fillAfter="true"
          android:fromYDelta="100%p"
          android:startOffset="100"
          android:toYDelta="50%p" /&gt;
    &lt;/set&gt;
  </code></pre>
  
  <p>and this is style xml</p>
  
  <pre><code>    &lt;style name="DialogAnimation"&gt;
      &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt;
      &lt;item name="android:windowEnterAnimation"&gt;@anim/slide_up_bottom_to_centre&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>Layout for dialog</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:id="@+id/mainlayout"
  
      android:layout_height="80dp"
      android:background="#E60000"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/txt_dia"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:layout_margin="10dp"
          android:text="Do you realy want to exit ?"
          android:textColor="@android:color/white"
          android:textSize="15dp"
          android:textStyle="bold" &gt;
      &lt;/TextView&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center"
          android:background="#3E80B4"
          android:orientation="horizontal" &gt;
  
          &lt;Button
              android:id="@+id/btn_yes"
              android:layout_width="100dp"
              android:layout_height="30dp"
              android:background="@android:color/white"
              android:clickable="true"
              android:text="Yes"
              android:textColor="#5DBCD2"
              android:textStyle="bold" /&gt;
  
          &lt;Button
              android:id="@+id/btn_no"
              android:layout_width="100dp"
              android:layout_height="30dp"
              android:layout_marginLeft="5dp"
              android:background="@android:color/white"
              android:clickable="true"
              android:text="No"
              android:textColor="#5DBCD2"
              android:textStyle="bold" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>can somebody please help how to show dialog after animation in centre only</p>