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!