Android 沉浸式状态栏
来源:互联网 发布:php判断来路域名 编辑:程序博客网 时间:2024/06/01 17:01
@TargetApi(Build.VERSION_CODES.LOLLIPOP)private void setTitleBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.setStatusBarColor(getResources().getColor(R.color.comm_1)); } else { setTheme(); }}/** * 如果是4.4以上系统设设置带颜色的状态栏 */@TargetApi(Build.VERSION_CODES.KITKAT)public void setTheme() { setTheme(null);}@TargetApi(Build.VERSION_CODES.KITKAT)public void setTheme(String color) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { View v = new View(this); ViewGroup.LayoutParams lParams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight()); if (color == null) { v.setBackgroundColor(getResources() .getColor(R.color.comm_1)); } else { v.setBackgroundColor(Color.parseColor(color)); } v.setLayoutParams(lParams); ViewGroup view = (ViewGroup) getWindow().getDecorView(); view.addView(v); Window window = getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); }}// 获取手机状态栏高度public int getStatusBarHeight() { Class<?> c = null; Object obj = null; Field field = null; int x = 0, statusBarHeight = 0; try { c = Class.forName("com.android.internal.R$dimen"); obj = c.newInstance(); field = c.getField("status_bar_height"); x = Integer.parseInt(field.get(obj).toString()); statusBarHeight = getResources().getDimensionPixelSize(x); } catch (Exception e1) { e1.printStackTrace(); } return statusBarHeight;}
1 0
- Android 沉浸式状态栏
- android 沉浸式 状态栏
- android 沉浸式状态栏
- android沉浸式状态栏
- Android沉浸式状态栏
- Android 沉浸式状态栏
- android 沉浸式状态栏
- Android沉浸式状态栏
- Android沉浸式状态栏
- Android 沉浸式状态栏
- Android沉浸式状态栏
- android 沉浸式状态栏
- android 沉浸式状态栏
- Android沉浸式状态栏
- android沉浸式状态栏
- Android 沉浸式状态栏
- android沉浸式状态栏
- Android沉浸式状态栏
- iOS UITextField自动换行
- HttpClient请求数据
- JavaWeb---response头--Refresh(刷新)、禁用浏览器缓存、响应体
- SDUT OJ 树结构练习——排序二叉树的中序遍历
- ROS进二阶学习笔记(1) TF 学习笔记2: -- TF Broadcaster 编写 (Python)
- Android 沉浸式状态栏
- ffmpeg进行视频转换和截取
- opencv 对数组(矩阵)的一些操作
- UFLDL Sparse Autoencoder
- 中国纺织企业迈入跨国布局新阶段
- 向剪切板复制文本的js库——clipboard.js
- 关于Lt分发系统的时序图分析
- 实现支付宝支付从底部弹窗效果
- Linux中的线程局部存储(二)