Search in sources :

Example 1 with SystemBarTintManager

use of com.lzy.imagepicker.view.SystemBarTintManager in project okhttp-OkGo by jeasonlzy.

the class BaseActivity method initSystemBarTint.

/** 设置状态栏颜色 */
protected void initSystemBarTint() {
    Window window = getWindow();
    if (translucentStatusBar()) {
        // 设置状态栏全透明
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        return;
    }
    // 沉浸式状态栏
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        //5.0以上使用原生方法
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(setStatusBarColor());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        //4.4-5.0使用三方工具类,有些4.4的手机有问题,这里为演示方便,不使用沉浸式
        //            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(setStatusBarColor());
    }
}
Also used : Window(android.view.Window) SystemBarTintManager(com.lzy.imagepicker.view.SystemBarTintManager)

Example 2 with SystemBarTintManager

use of com.lzy.imagepicker.view.SystemBarTintManager in project ImagePicker by jeasonlzy.

the class ImageBaseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setTranslucentStatus(true);
    }
    tintManager = new SystemBarTintManager(this);
    tintManager.setStatusBarTintEnabled(true);
    //设置上方状态栏的颜色
    tintManager.setStatusBarTintResource(R.color.status_bar);
}
Also used : SystemBarTintManager(com.lzy.imagepicker.view.SystemBarTintManager)

Aggregations

SystemBarTintManager (com.lzy.imagepicker.view.SystemBarTintManager)2 Window (android.view.Window)1