The main use of Https://github.com/jgilfelt/SystemBarTint this open source Library
1, import Systembartintmanager class
2, Basefragmentactivity's oncreate add the following code:
// Modify the status bar color, 4.4+ effective if (Build.VERSION.SDK_INT >= Build.version_codes. KITKAT) {settranslucentstatus (); } systembartintmanager Tintmanager = new Systembartintmanager (this ); Tintmanager.setstatusbartintenabled ( true ); Tintmanager.setstatusbartintresource (R.COLOR.STATUS_BAR_BG); // The notification bar needs the color, the color content in the Colors.xml file defines the
@TargetApi (protected) void settranslucentstatus () { = GetWindow (); // Translucent status Bar window.setflags ( WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); // Translucent navigation bar window.setflags ( WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); }
3, pay special attention to the following code, otherwise the display layout will be problematic:
<xmlns:android= "http://schemas.android.com/apk/res/android" Android : layout_width= "Match_parent" android:layout_height= "Match_parent" Android:background = "#f1f1f1" android:cliptopadding= "true" >
For more information on how to use: http://www.jcodecraeer.com/a/opensource/2014/1222/2198.html
Android Implementation transparent status bar