This code is working with no errors but it is not showing any animation in the dialog. Just added the 2 anim files for animation and added dialog.getWindow().setWindowAnimations(R.style.DialogTheme);
in the main java file.
also declared in styles.xml file.
but no animation is being shown.
I am new to android.

Main Activity

```
package com.dialog;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

//Custom Dialog
public void open(View view)
{
    final Dialog dialog= new Dialog(this);
    dialog.setContentView(R.layout.dialog);
    dialog.setTitle("Dialog");
    Button btnDismiss=(Button)dialog.findViewById(R.id.btnDismiss);
    Button btnOkay=(Button)dialog.findViewById(R.id.btnOkay);
    btnOkay.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(MainActivity.this,"Dialog     Successful",Toast.LENGTH_LONG).show();
            dialog.dismiss();
        }
    });
    btnDismiss.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.dismiss();
        }
    });
    dialog.getWindow().setWindowAnimations(R.style.DialogTheme);
    dialog.show();
}

public void close(View view)
{
    finish();
}

}

```

activity\_main.xml

```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Dialog App"
    android:id="@+id/tvApp"
    android:textSize="35dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView"
    android:src="@mipmap/ic_launcher"
    android:layout_below="@+id/tvApp"
    android:layout_marginTop="60dp"
    android:layout_alignRight="@+id/tvApp"
    android:layout_alignEnd="@+id/tvApp"
    android:layout_alignLeft="@+id/tvApp"
    android:layout_alignStart="@+id/tvApp" />
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Dialog"
    android:id="@+id/btnDialog"
    android:layout_below="@+id/imageView"
    android:layout_alignRight="@+id/tvApp"
    android:layout_alignEnd="@+id/tvApp"
    android:layout_marginTop="80dp"
    android:onClick="open"
    android:layout_alignLeft="@+id/imageView"
    android:layout_alignStart="@+id/imageView" />

</RelativeLayout>

```

styles.xml

```
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
<style name="DialogTheme">
    <item name="android:windowEnterAnimation">@anim/slide_left</item>
    <item name="android:windowExitAnimation">@anim/slide_right</item>
</style>
</resources>

```

@anim/slide\_left

```
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXDelta="100%p" android:toXDelta="0"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="5000" />
</set>

```

@anim/slide\_right

```
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="5000"
    android:fromXDelta="0%p"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:toXDelta="-100%p"  />
</set>

```

dialog.xml

```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<TextView
    android:text="Sure??"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="10dp"
    android:id="@+id/tvDismiss" />

<Button
    android:text="Okay"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/btnOkay"
    android:layout_below="@id/tvDismiss"
    android:layout_centerHorizontal="true" />

<Button
    android:text="Dismiss"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/btnDismiss"
    android:layout_below="@+id/btnOkay"
    android:layout_alignStart="@+id/btnOkay" />
<Button
    android:text="Exit"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/btnExit"
    android:layout_below="@+id/btnDismiss"
    android:layout_alignStart="@+id/btnOkay"
    android:onClick="close"/>
</RelativeLayout>

```