Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于toolbar陷入到状态栏问题 #279

Open
CK875430315 opened this issue Nov 7, 2019 · 5 comments
Open

关于toolbar陷入到状态栏问题 #279

CK875430315 opened this issue Nov 7, 2019 · 5 comments

Comments

@CK875430315
Copy link

setDarkMode和Slidr.attach(this) 结合好像不会出现,但是不配合就会有问题,如果不想侧滑退出只有加上android:fitsSystemWindows="true",怀疑Slidr这个库里加上了

@vodLee
Copy link

vodLee commented Dec 25, 2019

是不是setDarkModesetSystemUiVisibility这个地方的问题,这地方直接强制全屏了

@guobinAndroid
Copy link

是不是setDarkModesetSystemUiVisibility这个地方的问题,这地方直接强制全屏了

这个要怎么改?

@vodLee
Copy link

vodLee commented Apr 3, 2020

是不是setDarkModesetSystemUiVisibility这个地方的问题,这地方直接强制全屏了

这个要怎么改?

`
@TargetApi(Build.VERSION_CODES.M)
public static void setLightMode(Activity activity) {
setMIUIStatusBarDarkIcon(activity, true);
setMeizuStatusBarDarkIcon(activity, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}

@TargetApi(Build.VERSION_CODES.M)
public static void setDarkMode(Activity activity) {
    setMIUIStatusBarDarkIcon(activity, false);
    setMeizuStatusBarDarkIcon(activity, false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
}

`

我遇到的问题是 util 的源代码中直接set导致,所以先vis = getSystemUiVisibility(),然后setSystemUiVisibility (vis & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR),当时大概是这么写的,demo找不到了。

思路的话当时看 setDarkModesetLightMode 的差距,在 View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 这个常量上,看源码这个常量是只有一位是1的整形,盲猜底层是靠位运算去判断的。

所以这个地方先通过 get 方法获取原 activity 的 SystemUi,通过位运算去设置View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 对应的值,然后再通过set方法设置到 activity 的 SystemUi 上,解决了我当时的问题

@vodLee
Copy link

vodLee commented Apr 3, 2020

是不是setDarkModesetSystemUiVisibility这个地方的问题,这地方直接强制全屏了

这个要怎么改?

`
@TargetApi(Build.VERSION_CODES.M)
public static void setLightMode(Activity activity) {
setMIUIStatusBarDarkIcon(activity, true);
setMeizuStatusBarDarkIcon(activity, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}

@TargetApi(Build.VERSION_CODES.M)
public static void setDarkMode(Activity activity) {
    setMIUIStatusBarDarkIcon(activity, false);
    setMeizuStatusBarDarkIcon(activity, false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
}

`

我遇到的问题是 util 的源代码中直接set导致,所以先vis = getSystemUiVisibility(),然后setSystemUiVisibility (vis & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR),当时大概是这么写的,demo找不到了。

思路的话当时看 setDarkModesetLightMode 的差距,在 View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 这个常量上,看源码这个常量是只有一位是1的整形,盲猜底层是靠位运算去判断的。

所以这个地方先通过 get 方法获取原 activity 的 SystemUi,通过位运算去设置View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 对应的值,然后再通过set方法设置到 activity 的 SystemUi 上,解决了我当时的问题

刚才找到了以前的代码

@TargetApi(Build.VERSION_CODES.M)
public static void setLightMode(Activity activity) {
setMIUIStatusBarDarkIcon(activity, true);
setMeizuStatusBarDarkIcon(activity, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int visibility = activity.getWindow().getDecorView().getSystemUiVisibility();
if (visibility != (visibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)) {
visibility = visibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
activity.getWindow().getDecorView().setSystemUiVisibility(visibility);
}
}
@TargetApi(Build.VERSION_CODES.M)
public static void setDarkMode(Activity activity) {
    setMIUIStatusBarDarkIcon(activity, false);
    setMeizuStatusBarDarkIcon(activity, false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int visibility = activity.getWindow().getDecorView().getSystemUiVisibility();
        if (visibility == (visibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)) {
            visibility = visibility ^ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        activity.getWindow().getDecorView().setSystemUiVisibility(visibility);
    }
}

@guobinAndroid
Copy link

是不是setDarkModesetSystemUiVisibility这个地方的问题,这地方直接强制全屏了

这个要怎么改?

`
@TargetApi(Build.VERSION_CODES.M)
public static void setLightMode(Activity activity) {
setMIUIStatusBarDarkIcon(activity, true);
setMeizuStatusBarDarkIcon(activity, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}

@TargetApi(Build.VERSION_CODES.M)
public static void setDarkMode(Activity activity) {
    setMIUIStatusBarDarkIcon(activity, false);
    setMeizuStatusBarDarkIcon(activity, false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
}

我遇到的问题是 util 的源代码中直接set导致,所以先vis = getSystemUiVisibility(),然后setSystemUiVisibility (vis & ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR),当时大概是这么写的,demo找不到了。 思路的话当时看 setDarkModesetLightMode的差距,在View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 这个常量上,看源码这个常量是只有一位是1的整形,盲猜底层是靠位运算去判断的。 所以这个地方先通过 get 方法获取原 activity 的 SystemUi,通过位运算去设置View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR` 对应的值,然后再通过set方法设置到 activity 的 SystemUi 上,解决了我当时的问题

刚才找到了以前的代码

@TargetApi(Build.VERSION_CODES.M)
public static void setLightMode(Activity activity) {
setMIUIStatusBarDarkIcon(activity, true);
setMeizuStatusBarDarkIcon(activity, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int visibility = activity.getWindow().getDecorView().getSystemUiVisibility();
if (visibility != (visibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)) {
visibility = visibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
}
activity.getWindow().getDecorView().setSystemUiVisibility(visibility);
}
}
@TargetApi(Build.VERSION_CODES.M)
public static void setDarkMode(Activity activity) {
    setMIUIStatusBarDarkIcon(activity, false);
    setMeizuStatusBarDarkIcon(activity, false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        int visibility = activity.getWindow().getDecorView().getSystemUiVisibility();
        if (visibility == (visibility | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)) {
            visibility = visibility ^ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
        activity.getWindow().getDecorView().setSystemUiVisibility(visibility);
    }
}

谢谢哈,我已经解决了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants