zoukankan      html  css  js  c++  java
  • android 沉浸式状态栏

      搜了下,发现原来设置状态栏居然有个很高大上的名字(听不懂的都是高大上)——沉浸式状态栏,Android4.4以后开始支持沉浸式状态栏, 继续搜索,发现,有一个很简单的开源项目——SystemBarTint,可以很完美的支持沉浸式状态栏。

        SystemBarTint地址: https://github.com/hexiaochun/SystemBarTint


    应用 :
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.4'



    只有在4.4 系统后才能有
    style
    <!-- 去掉tab顶部的黑边 -->
    <style name="no_title" parent="@android:style/Theme.Light.NoTitleBar">

    <!-- 沉浸式状态栏 -->
    <item name="android:fitsSystemWindows">true</item>
    <item name="android:clipToPadding">false</item>
    </style>


    在activity 中进行展示

    在baseActivity基类中 的setContent();
    后面要进行设置
     ViewGroup contentFrameLayout = (ViewGroup) findViewById(Window.ID_ANDROID_CONTENT);
            View parentView = contentFrameLayout.getChildAt(0);
            if (parentView != null && Build.VERSION.SDK_INT >= 14) {
                parentView.setFitsSystemWindows(true);
            }
    为给每个布局的基布局设置次属性
     
     

    /**
    * Apply KitKat specific translucency.
    */
    private void applyKitKatTranslucency() {

    // KitKat translucent navigation/status bar.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    setTranslucentStatus(true);
    SystemBarTintManager mTintManager = new SystemBarTintManager(this);
    mTintManager.setStatusBarTintEnabled(true);

    mTintManager.setStatusBarTintResource(R.color.colorPrimary);//通知栏所需颜色
    }

    }

    @TargetApi(19)
    private void setTranslucentStatus(boolean on) {
    Window win = getWindow();
    WindowManager.LayoutParams winParams = win.getAttributes();
    final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if (on) {
    winParams.flags |= bits;
    } else {
    winParams.flags &= ~bits;
    }
    win.setAttributes(winParams);
    }







    另外还可以 看弘扬--> http://blog.csdn.net/lmj623565791/article/details/48649563

  • 相关阅读:
    树链剖分 (模板) 洛谷3384
    ST表 (模板) 洛谷3865
    IOI 2005 River (洛谷 3354)
    IOI 2005 River (洛谷 3354)
    poj1094 Sorting It All Out
    poj1094 Sorting It All Out
    spfa(模板)
    HAOI 2006 受欢迎的牛 (洛谷2341)
    HAOI 2006 受欢迎的牛 (洛谷2341)
    洛谷1850(NOIp2016) 换教室——期望dp
  • 原文地址:https://www.cnblogs.com/jeno-song/p/5604589.html
Copyright © 2011-2022 走看看