Android background map and status bar fusion method

Let's look at the code first:

Since this function is only supported by Android 5.0 and above systems, we first judge the system version number in the code. The following code will be executed only when the version number is greater than or equal to 21, that is, 5.0 and above systems.

Then we call the getwindow(). Getdecorview() method to get the currently active decorview, and then call its setsystemuivisibility() method to change the display of the system UI. Here, we pass in view.system_ UI_ FLAG_ LAYOUT_ Fullscreen and view.system_ UI_ FLAG_ LAYOUT_ STABLE means that the layout of the activity will be displayed on the status bar. Finally, call the setStatusBarColor () method to set the status bar to transparent color.

Just these codes can achieve the effect of integrating the background image and the status bar.

However, if you run the program, you will find that there are still some problems. The header layout of the interface is almost close to the system status bar. This is because the system status bar has become a part of our layout, so there is no separate space for it. Of course, this problem is also very easy to solve. Just use the Android: fitssystemwindows attribute.

See code:

That's it.

The above integration method of Android implementation background map and status bar is all the content shared by Xiaobian. I hope it can give you a reference and support more 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
分享
二维码
< <上一篇
下一篇>>