Implementation method of transparent effect of virtual navigation key in Android status bar

The status bar and virtual navigation keys are translucent on 4.4, and can be fully transparent above 5.0

First effect

4.4 translucent effect

5.0 and above fully transparent effect

Upper code

Mainactivity code

activity_ Main.xml Code:

The above lines of code in 5.0 are not well understood. It needs to be added from the source code. Find out what these methods are used for in the future, and then come back to indicate

Setstatusbarcolor source code

Setnavigationbarcolor source method

The fitssystemwindows property must be set to true, otherwise the layout will overlap with the status bar

As shown in the figure:

There are two ways:

Method 1 (add attribute to XML file root layout):

Mode 2 (set in the code):

In fact, there is a third way to solve this problem. Obtain the height of the status bar and set an equal height view on the top

Source address: https://github.com/StormSunCC/MyCompatStatusBar

The above is the implementation method of the transparent effect of the virtual navigation key in the Android status bar introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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