Detailed explanation of Android immersive implementation compatibility solutions

Since Android 5.0, immersive status bar seems to have become a trend. The lack of immersive status bar in applications always feels less. Therefore, I began to look everywhere for how to be compatible with the lower version of immersive. Due to the span of Android platform, I always encountered some unsatisfactory problems. Finally, Huangtian is worthy of those who have a heart. By referring to some information on the network and some experience in development, Huangtian summarizes a feasible and good solution!

First, what is the immersive status bar?

Immersive. It is required that the Android status bar and the title bar (actionbar / toolbar) have the same color in the application, or use the continuous background of the same figure.

Don't say much, light your sword!

The specific implementation needs to deal with different Android versions, decorview and activity XML layout file root layout control.

Java code, setting immersive methods

Note: the acquisition of rootview (i.e. decorview) and window is no longer stated here!

①.ApkUtil.getColor(this,colorResId)

② . get status bar height

Add the following properties to the activity layout XML root layout

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

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
分享
二维码
< <上一篇
下一篇>>