沉浸式状态栏

2018-06-19  本文已影响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;
}

上一篇下一篇

猜你喜欢

热点阅读