不用找了,你的需求,我这里都有,下面 给大家贴出效果图
给大家粘一个我的Utils
public class StatusBarUtils {
private Activity mActivity;
//状态栏颜色
private int mColor = -1;
//状态栏drawble
private Drawable mDrawable;
//是否是最外层布局是 DrawerLayout 的侧滑菜单
private boolean mIsDrawerLayout;
//是否包含 ActionBar
private boolean mIsActionBar;
//侧滑菜单页面的内容视图
private int mContentResourseIdInDrawer;
public StatusBarUtils(Activity activity) {
mActivity = activity;
}
public static StatusBarUtils with(Activity activity) {
return new StatusBarUtils(activity);
}
public int getColor() {
return mColor;
}
public StatusBarUtils setColor(int color) {
mColor = color;
return this;
}
public Drawable getDrawable() {
return mDrawable;
}
public StatusBarUtils setDrawable(Drawable drawable) {
mDrawable = drawable;
return this;
}
public boolean isDrawerLayout() {
return mIsDrawerLayout;
}
public boolean isActionBar() {
return mIsActionBar;
}
public StatusBarUtils setIsActionBar(boolean actionBar) {
mIsActionBar = actionBar;
return this;
}
/**
* 是否是最外层布局为 DrawerLayout 的侧滑菜单
*
* @param drawerLayout 是否最外层布局为 DrawerLayout
* @param contentId 内容视图的 id
* @return
*/
public StatusBarUtils setDrawerLayoutContentId(boolean drawerLayout, int contentId) {
mIsDrawerLayout = drawerLayout;
mContentResourseIdInDrawer = contentId;
return this;
}
public void init() {
fullScreen(mActivity);
if (mColor != -1) {
//设置了状态栏颜色
addStatusViewWithColor(mActivity, mColor);
}
if (mDrawable != null) {
//设置了状态栏 drawble,例如渐变色
addStatusViewWithDrawble(mActivity, mDrawable);
}
if (isDrawerLayout()) {
//未设置 fitsSystemWindows 且是侧滑菜单,需要设置 fitsSystemWindows 以解决 4.4 上侧滑菜单上方白条问题
fitsSystemWindows(mActivity);
}
if (isActionBar()) {
//要增加内容视图的 paddingTop,否则内容被 ActionBar 遮盖
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
ViewGroup rootView = (ViewGroup) mActivity.getWindow().getDecorView().findViewById(android.R.id.content);
rootView.setPadding(0, getStatusBarHeight(mActivity) + getActionBarHeight(mActivity), 0, 0);
}
}
}
/**
* 去除 ActionBar 阴影
*/
public StatusBarUtils clearActionBarShadow() {
if (<