Android programming method for setting the entry and exit effects of activity

This article describes the method of Android programming to set the entry and exit effects of activity. Share with you for your reference, as follows:

After reading the Android source code and resource files, I finally understand how to modify the entry and exit effects of setting dialog and activity. Set dialog. First obtain its window through getwindow() method, and then obtain windowmanager.layoutparams LP of window through getattributes() method. LP has a public attribute windowanimations. Just assign the ID of the animation to be implemented to it. The problem is how to write this animation. The study found that the effects of window entry and exit are set through @ Android: windowsenteranimation and @ Android: windowsexitanimation respectively. For example, the anim when entering is @ anim / dialog_ Enter, exit @ anim / dialog_ Exit, declare a style as:

Then pass the style ID to LP. Windowanimations.

The entry and exit effects of an activity can be set through the items @ Android: activityopenenteranimation, @ Android: activityopenexitanimation, @ Android: activitycloseenteranimation, @ Android: activitycloseexitanimation. The first indicates that the new activity has created an entry effect, and the second indicates that the activity has not finished yet, The third represents the entry effect returned by the previous activity, and the fourth represents the exit effect after activity finish()... (it seems a little messy). The specific settings are as follows:

Then take mytheme as the theme of the activity. Another way is to obtain its window through acitvity and set it like setting dialog, because in the final analysis, it is to set the windowanimations value in the layoutparams of window. Therefore, the entry and exit effects of activity can also be set through @ Android: windowsenteranimation and @ Android: windowsexitanimation.

For more Android related content, readers interested can see the special topics of this site: activity operation skills summary of Android programming, introduction and advanced tutorial of Android development, @l)u 419)u 2@, Android database operation skills summary, Android view skills summary and Android control usage summary

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>