美文网首页
沉浸式状态栏

沉浸式状态栏

作者: 文强小弟 | 来源:发表于2018-06-19 18:04 被阅读0次

    沉浸式状态栏

    参考:http://www.jcodecraeer.com/a/opensource/2017/0526/7976.html
    app/build.gradle中dependencies{
    //状态栏
    implementation 'com.gyf.barlibrary:barlibrary:2.3.0'
    }

    /**
    * 开启沉浸式模式 设置透明度
    /
    protected void fullScreen(float alpha) {
    mImmersionBar = ImmersionBar.with(this);
    mImmersionBar.statusBarAlpha(alpha).init();
    RelativeLayout relativeLayout = findViewById(R.id.navigation_bar);
    if (relativeLayout != null) {
    relativeLayout.setPadding(0, getStatusBarHeight(), 0, 0);
    }
    }
    /
    *
    * @return 获取状态栏的高度
    */
    protected int getStatusBarHeight() {
    int result = 0;
    int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
    if (resourceId > 0) {
    result = getResources().getDimensionPixelSize(resourceId);
    }
    return result;
    }

    相关文章

      网友评论

          本文标题:沉浸式状态栏

          本文链接:https://www.haomeiwen.com/subject/puaaeftx.html