Android screen switching monitoring example code
•
Android
Yesterday, I tried to make the view display in different positions when switching the screen. I searched some information on the Internet. I did it myself for a period of time and finally completed the function.
Since screen switching will call each life cycle of activity, you need to add code to the activity attribute of manifest
Then rewrite onconfigurationchanged () and add your own processing code
In the code, I judge the horizontal screen and vertical screen, and let the rear display different layouts.
Rewrite the onconfigurationchanged () in the custom view. When the screen switches, this code will be executed three times. I don't know why.
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
二维码