Android 代码修改状态栏底部颜色

264 阅读1分钟
public class WindowsUtils {

    @RequiresApi(api = Build.VERSION_CODES.N)
    public static void setStatusBarColor(Window window, Resources resources, int id){
        //After LOLLIPOP not translucent status bar
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //Then call setStatusBarColor.
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(resources.getColor(id));
    }
}