直播视频app源码,Android获取状态栏高度,动态设置控件高度
1、获取直播视频app源码状态栏高度
```handlebars //获取status_bar_height资源的ID int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { //根据资源ID获取响应的尺寸值 int statusBarHeight = getResources().getDimensionPixelSize(resourceId); SPUtils.putInt(Constant.STATUSBAR_HEIGHT,statusBarHeight); } ```
2、动态设置直播视频app源码控件高度
```handlebars int statusBarHeight = SPUtils.getInt(Constant.STATUSBAR_HEIGHT, 0); if (statusBarHeight > 0) { LinearLayout.LayoutParams sp_params = new LinearLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); sp_params.height = statusBarHeight; mvView.setLayoutParams(sp_params); } ```
3、务必保持一致 ( LinearLayout. LinearLayout.LayoutParams 与需要设置的控件父控件)
```handlebars LinearLayout.LayoutParams <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <View android:id="@+id/mv_view" android:layout_width="match_parent" android:layout_height="@dimen/statusbar_height" android:background="@color/colorTheme" android:visibility="visible" /> </LinearLayout> ```
以上就是 直播视频app源码,Android获取状态栏高度,动态设置控件高度,更多内容欢迎关注之后的文章