Android 5.0版本开发及以上版本的沉浸式状态栏实例
程序员文章站
2023-11-01 08:30:04
方法一:(5.1.1,6.0.1,7.1.2通用)
try {
if (build.version.sdk_int >= build.version_codes.lollipop) {...
方法一:(5.1.1,6.0.1,7.1.2通用)
try { if (build.version.sdk_int >= build.version_codes.lollipop) { window window = getwindow(); window.addflags(windowmanager.layoutparams.flag_draws_system_bar_backgrounds); window.setstatusbarcolor(color.parsecolor(reapalconfig.theme_color)); //底部导航栏 window.setnavigationbarcolor(color.parsecolor(reapalconfig.theme_color)); } } catch (exception e) { e.printstacktrace(); }
请将以上代码设置在你setcontentview之前即可实现
看下效果图:
方法二:
设置状态栏不可见:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.activity_wait_aty); init(); }
方法三:
设置状态栏和导航栏为透明的
if (build.version.sdk_int >= build.version_codes.kitkat) { window window = getwindow(); // translucent status bar window.addflags(windowmanager.layoutparams.flag_translucent_status); // translucent navigation bar window.addflags(windowmanager.layoutparams.flag_translucent_navigation); }
上一篇: 祛斑的方法 5大食物不给色斑留机会
下一篇: 医疗网络seo推广走哪条路合适