Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animate custom Dialog programmatically

I would like to set some animations to my custom dialog and I would like to do it programmatically. I know I can do it like this with xml animations:

<style name="DialogAnimation">
    <item name="android:windowEnterAnimation">@anim/slide_up_dialog</item>
    <item name="android:windowExitAnimation">@anim/slide_out_down</item>
</style>


Dialog imageDiaglog= new Dialog(MainActivity.this,R.style.DialogAnimation);

But I would like to do it programmatically. How can I set my programmatically created animations to Dialog's show() and hide() methods?

Thank you.

like image 215
user4386126 Avatar asked Jun 30 '15 17:06

user4386126


1 Answers

You cant because the dialog uses the style element for the animation transition. And You cannot set the style elements programmatically.

like image 106
Hardik Chauhan Avatar answered Oct 13 '22 00:10

Hardik Chauhan