哎,太失望了。中国的技术,都是别人出来半年了才传播过来。
不说了。侵入式菜单,我在网上找了一堆,都没有解决我的问题。看着他们写的 博客,弄了半天没弄出来,只能说明,他们写的不通俗易懂。
想实现qq的那种效果,老是不行。就空间的那种,图片占据了状态栏。
但是状态栏的颜色,我还是可以改变的:
compile 'com.jaeger.statusbaruitl:library:1.0.0'
setContentView(R.layout.activity_main);
StatusBarUtil.setColor(this,getResources().getColor(R.color.colorPrimary));
如果用SystemBarTint开源类,我们就可以主动改变状态栏的颜色,但是只能设置单色,不能像上面一样随着背景的改变而改变。
1.需要在主题中设置:
<style name="FullBleedTheme" parent="android:Theme.Holo.Light.NoActionBar.TranslucentDecor">
这个其实就是设置了:
<style name="Theme.Holo.Light.NoActionBar.TranslucentDecor">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
就相当于在代码中设置,需要在在setContentView(layoutResID)之前调用
if(VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
//透明状态栏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//透明导航栏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
注意引用
ompile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
2.然后在布局的最外层或者activity的主题中设置:
android:fitsSystemWindows="true"
3.然后在setContentView(layoutResID)之后调用代码:
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintColor(Color.parseColor("#222231"));
妈的,这就让我知道了,学习东西,重要的不是看别人的博客,而是拿到 一个可以运行的demo,然后你才会少走很多坑。 官方都没有给你说要弄这么多的步骤。