Coder Social home page Coder Social logo

Comments (8)

LcTerry avatar LcTerry commented on May 27, 2024 2

@laobie 我后面自己找方法,在4.4 5.0 6.0上都成功了。
public static void setTranslucentStatus(Activity activity){ Window window = activity.getWindow(); 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){ window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } }
就用这一个方法就够了。只控制了状态栏!过滤掉虚拟键盘,而不会引发虚拟键盘遮挡布局的问题

from statusbarutil.

csgsky avatar csgsky commented on May 27, 2024

activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); 设置浸没之后,上面这行代码应该去掉吧,麻烦您看一下。

from statusbarutil.

csgsky avatar csgsky commented on May 27, 2024

StatusBarUtil.setTranslucentForCoordinatorLayout(this, 0);
this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
这样写解决了

from statusbarutil.

laobie avatar laobie commented on May 27, 2024

@csgsky 好的,我今天抽时间看一下,之前这么做是因为需要做兼容来着,具体哪个地方我也忘了

from statusbarutil.

BloodBamboo avatar BloodBamboo commented on May 27, 2024

这个现实我也出现过,我的环境是htc平板,6.0的系统,.
由于设置了透明,下方的导航栏就盖在布局上,.
比如,布局底部有个按钮,导航栏就挡住了,按钮不能点击

from statusbarutil.

laobie avatar laobie commented on May 27, 2024

@yx19861211 你试试楼上说的,添加这个可以不,你用的是哪个方法呢?

this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

from statusbarutil.

BloodBamboo avatar BloodBamboo commented on May 27, 2024

@laobie
20161019_112145
20161019_112211

this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
用了是不档了,但是显示的也不是 想要的效果,不用的话就是挡住的,
我的解决办法是:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
} else {
setColorNoTranslucent(activity, color);
}
就是设置一下透明,别的都不设置

from statusbarutil.

LcTerry avatar LcTerry commented on May 27, 2024

@BloodBamboo 这样你的顶部状态栏就没有效果了
@laobie 能在6.0上实现顶部状态栏透明,底部虚拟按键位置不变吗?我用的 StatusBarUtil.setTranslucent(this, 0);
按照@csgsky 的 .clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
后顶部直接变透明,但是没有没有变成我需要的toolbar上设置的颜色

from statusbarutil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.