Animation not working the in custom dialog

android dialog animation slide
how to set animation in dialog
progress dialog with animation in android
dialog zoom in animation android
animated dialog android github
android dialog animation programmatically
android custom dialog rounded corners
android custom popup dialog example

I have made the custom dialog following this link and its working perfectly all fine. but then I think to add the animation , so that it looks like coming from the to of the screen to the bottom side. So I searched for these two animations and found them And I put them in the anim folder. so to apply them in my custom dialog I have changed the constructor a little bit . I have added this line in the constructor of the custom dialog

 public AnimationDialog(Activity a, int drawable) {
    super(a);
    // TODO Auto-generated constructor stub
    this.c = a;
    this.mDrawable = drawable;
    this.getWindow().getAttributes().windowAnimations = R.style.DialogSlideAnim;
}

the following line is what I have added to achieve the animation as shown above

this.getWindow().getAttributes().windowAnimations = R.style.DialogSlideAnim;

but nothing happens , my dialog appear as it appears by default

and here is my style file for reference

 <style name="DialogAnimation">
    <item name="android:windowEnterAnimation">@anim/slide_down_animation</item>
    <item name="android:windowExitAnimation">@anim/slide_up_animation</item>
</style>

<!-- Animation for dialog box -->
<style name="DialogSlideAnim" parent="@android:style/Theme.Dialog">
    <item name="android:windowAnimationStyle">@style/DialogAnimation</item>
</style>

But still my animation is not working , what I am doing wrong , ? please tell me How can I achieve this ? How can I animate my custom dialog.

Edit

this is my slide down animation

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:fromYDelta="0%p"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toYDelta="100%p" />

</set>

this is my slide up animation

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

Try this:

slide_down_animation.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:fromYDelta="-100%p"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toYDelta="0%p" />
</set>

and

slide_up_animation.xml

<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="@android:integer/config_mediumAnimTime"
        android:fromYDelta="0%p"
        android:interpolator="@android:anim/accelerate_interpolator"
        android:toYDelta="-100%p" />
</set>

EDIT:

Apart from that, you can also try setting your style this way:

getWindow().setWindowAnimations(R.style.DialogAnimation);

(NOT R.style.DialogSlideAnim)

android - Custom Dialog Shown Animation Not Working, It's not smooth. So I add y translation to 150%, and the dialog will slide in and out completely across the bottom of window. @omieliekh 's solution allows full customization of the dialog animations, however this always applies globally to all dialogs and I could not get this solution to work only on one instance of a material dialog.

Attach animation in style.xml for DialogFragment in onStart() callback funcation

@Override
public void onStart() {
  super.onStart();

  if (getDialog() == null) {
    return;
  }

  // set the animations to use on showing and hiding the dialog
  getDialog().getWindow().setWindowAnimations(R.style.DialogAnimation);

}

Economic and Business Analysis: Quantitative Methods Using , The alert dialog and its builder are a great example. While there is android:text​="Animated Dialog Sample" /> dialog? Probably not. Transgender employees in tech: Why this "progressive" industry has more work to do  Showing Dialog With Animation In Android In this video, we will create a dialog and show it with some animation: - Slide left to right. - Slide up to down.

Try this:

slide_down.xml

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

slide_up.xml

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

in style.xml add this style

 <style name="DialogStyle" 
    parent="Theme.MaterialComponents.DayNight.Dialog.Bridge">
    <item name="android:windowNoTitle">true</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorPrimary">@color/colorPrimary</item>

    <!-- Additionally if you want animations when dialog opening -->
    <item name="android:windowEnterAnimation">@anim/slide_up</item>
    <item name="android:windowExitAnimation">@anim/slide_down</item>
</style>

then in on the start of the dialog add this

 @Override
public void onStart() {
    super.onStart();
    if (getDialog() == null||getDialog().getWindow() == null) {
        return;
    }
    getDialog().getWindow().setWindowAnimations(R.style.DialogStyle);

}

Up down animation for dialog fragment · GitHub, In This tutorial, I am going to create a custom dialog with animation android shows how to replace the associated on and off screen transitions of an alert dialog  android.widget.PopupWindow is another class that provide popup window function besides AlertDialog. There are something different between them. This example will show you how to use android.widget.PopupWindow in android application. 1. PopupWindow And […]

Add custom transitions to Android alert dialogs, Then I decided to develop a library for it which will help many developers to implement such dialog easily in their Android apps. After this, I started work on it and  Dialog, was defined in doc, is a small window that prompts the user to make a decision or enter additional information.A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.

Create custom dialog with animation android, Let's start by providing the code for creating a completely custom dialog based on an XML view. If you are having any issues, be sure to use the checklist below: The dialog progress animation can be customized by supplying your own  And also, if you set the y translation to 100%, the dialog will disappear when it's bottom edge gets to the bottom of window. Thus we will see a flash. It's not smooth. So I add y translation to 150%, and the dialog will slide in and out completely across the bottom of window.

Animated Material Dialog, A subtle animation when a dialog appears and disappears makes the UI change Animations not based on physics—such as those built with  How to Create a Rate Me Dialog with the Android-Rate Library - Android Studio Tutorial - Duration: 6:32. Coding in Flow 18,115 views

Comments
  • Where are you setting your animationStyle?
  • this.getWindow().getAttributes().windowAnimations = R.style.DialogSlideAnim; in constructor
  • Are you sure you didn't mix up two animation resources (names would suggest so...)? Show us your anim resources.
  • @BartoszLipinski question edited
  • Did you try everything in that I posted in the answer?
  • but its very speedy ? how to control its speed
  • Change the android:duration parameter in your anim resources. You can use milliseconds there. So for example instead of this: android:duration="@android:integer/config_mediumAnimTime" you can use this android:duration="600"
  • android:duration="@android:integer/config_mediumAnimTime" what do you think is this timing ?
  • You should be able to check it by clicking config_mediumAnimTime with your mouse button while holding ctrl/command button. It's 400 milliseconds.