Android(安卓)获取statusBar的高度 设置statusBar为透明色
16lz
2021-01-24
写一些小方法 用着好着方便
// 获取statusbar的高度 public int getStatusBarHeight(){ int result = 0; int resourceId = getResources().getIdentifier("status_bar_height","dimen","android"); if (resourceId > 0){ result = getResources().getDimensionPixelOffset(resourceId); } return result;}
二、StatusBar设置透明色:
1.在需要的style中,如下设置:
2.在需要的acivity.xml中设置
android:theme="@style/AppTheme"
如果整个app都是需要可以在application中设置。
3.需要的activity.xml中设置:
android:fitsSystemWindows="true"
更多相关文章
- Android开发之Shape和Selector、Layer-list的详解
- android studio适配器Adapter
- Android控件拖拽功能的实现
- ListView 样式自定义
- android listview、GridView中item点击后改变其他item中的状态 s
- Android(安卓)相关区域高度获取
- color 颜色代码 android res/values/colors.xml
- android SpannableString
- Android(安卓)中颜色对应的值