Android沉浸式(透明任务栏)任务栏
//透明状态栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//透明导航栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
2021.1.14补:需要注意的是,再单独设置透明任务栏后,任务栏会和布局产生重叠,我们可以再layout的布局中添加代码设置(划重点:是layout的布局文件中,而不是AndroidManifest.xml文件)
android:clipToPadding="true"
android:fitsSystemWindows="true"
参考文章:https://www.cnblogs.com/newcaoguo/p/5801932.html
Android获取menu菜单中的item组件
直接使用findViewById无法获取到item组件,可以使用如下方法获取到item组件
private MenuItem item; @Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); item=menu.findItem(R.id.navigation_find).setChecked(true); return true; }
参考文章:https://www.cnblogs.com/anee/archive/2011/11/25/2675807.html