资源简介
android状态栏一体化,沉浸式状态栏,状态栏管理类,自动管理工具类
代码片段和文件信息
package com.hdl.newkjdemo.newkjdemo.utils;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.frameLayout.LayoutParams;
import java.lang.reflect.Method;
@SuppressWarnings({“unchecked“ “rawtypes“})
public class SystemStatusManager {
Activity mContext;
public void setTranslucentStatus(int res) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// 透明状态栏
this.mContext.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// 透明导航栏
this.mContext.getWindow().addFlags(
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
SystemStatusManager tintManager = new SystemStatusManager(this.mContext);
tintManager.setStatusBarTintEnabled(true);
// 设置状态栏的颜色
tintManager.setStatusBarTintResource(res);
this.mContext.getWindow().getDecorView().setFitsSystemWindows(true);
}
}
static {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
try {
Class c = Class.forName(“android.os.SystemProperties“);
Method m = c.getDeclaredMethod(“get“ String.class);
m.setAccessible(true);
sNavBarOverride = (String) m.invoke(null “qemu.hw.mainkeys“);
} catch (Throwable e) {
sNavBarOverride = null;
}
}
}
/**
* The default system bar tint color value.
*/
public static final int DEFAULT_TINT_COLOR = 0x99000000;
private static String sNavBarOverride;
private final SystemBarConfig mConfig;
private boolean mStatusBarAvailable;
private boolean mNavBarAvailable;
private boolean mStatusBarTintEnabled;
private boolean mNavBarTintEnabled;
private View mStatusBarTintView;
private View mNavBarTintView;
/**
* Constructor. Call this in the host activity onCreate method after its
* content view has been set. You should always create new instances when
* the host activity is recreated.
*
* @param activity The host activity.
*/
@TargetApi(19)
public SystemStatusManager(Activity activity) {
this.mContext = activity;
Window win = activity.getWindow();
ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 20318 2017-11-09 09:42 SystemStatusManager\SystemStatusManager.java
文件 474 2017-11-09 09:42 SystemStatusManager\使用方法.txt
目录 0 2017-11-09 09:22 SystemStatusManager
----------- --------- ---------- ----- ----
20792 3
评论
共有 条评论