码迷,mamicode.com
首页 > 移动开发 > 详细

android 4.4 状态栏隐藏

时间:2015-09-30 16:04:04      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:

这个是Android Developer上的原文 反正我也看得不是很懂 我知道的就是实现和导航栏和状态栏的透明 带一些渐变效果

1. 设置主题

<style name="Theme.Timetodo" parent="@android:style/Theme.Holo.Light">
    <!-- translucent system bars -->
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>

技术分享
添加了这两个属性之后 就是是这个效果了 可以看到 listview已经被顶到上面去了 不知道是不是bug 查了下资料 目前的解决办法好像都是给layout设置padding来解决

2.设置颜色和设置padding

private void initSystemBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setTranslucentStatus(true);
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintResource(R.color.actionbar_bg);
        SystemBarConfig config = tintManager.getConfig();
        listViewDrawer.setPadding(0, config.getPixelInsetTop(true), 0, config.getPixelInsetBottom());
    }
}

3.最终效果

技术分享

参考资料:

http://mindofaandroiddev.wordpress.com/2013/12/28/making-the-status-bar-and-navigation-bar-transparent-with-a-listview-on-android-4-4-kitkat/

http://stackoverflow.com/questions/20781014/translucent-system-bars-and-content-margin-in-kitkat

android 4.4 状态栏隐藏

标签:

原文地址:http://www.cnblogs.com/ArRan/p/4849113.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!