Looking at the source and resource files of Android, finally understand how to modify settings dialog and activity entry and exit effects. Setting dialog first obtains its window through the GetWindow () method, and then obtains the Windowmanager.layoutparams LP of Window through the GetAttributes () method, LP has a public property windowanimations, so long as the ID of the animation to be implemented is assigned to it. The question is how the animation should be written, and the study found that the effects of window entry and exit were set by @android: Windowenteranimation and @android:windowexitanimation two item, For example, when entering the Anim is @anim/dialog_enter, exit is @anim/dialog_exit, then declare a style:
<style name="mydialog"> <item name="@android: Windowenteranimation"> @anim/dialog_enter</item> <item name="@android : Windowexitanimation"> @anim/dialog_exit</item></style>
Then pass the ID of this style to lp.windowanimations on the line.
Activity entry and exit effects can be achieved by @android: Activityopenenteranimation, @android: Activityopenexitanimation, @android: Activitycloseenteranimation, @android: activitycloseexitanimation These item settings, the first represents a new activity to create an entry effect, The 2nd indicates that the activity has not finished () the exit effect, the 3rd indicates that the previous activity returned the entry effect, and the 4th represents the activity finish () Exit effect ... (It seems a bit messy). The specific settings refer to the following:
<style name="myact"> <item name="@android: Activityopenenteranimation"> @anim/act_enter</item> <item name="@android: Activityopenexitanimation"> @anim/act_exit</item> <item name="@android: Activitycloseenteranimation"> @anim/act_enter</item> <item name="@android: Activitycloseexitanimation"> @anim/act_exit</item> </style> <style name="MyTheme"Parent="@android: Style/theme"> <item name="@android: Windowanimationstyle"> @style/myact</item> </style>
And then the MyTheme this style as the activity of the theme on the line, there is another way is to get its window through acitvity, and then set the same settings as dialog, Because the windowanimations value in the layoutparams of the window is set in the final analysis. So the activity's entry and exit effects can also be @android:windowenteranimation and @android: windowexitanimation these two item settings.
Android to set activity entry and exit effects