沉浸式
来源:互联网 发布:淘宝怎么看店铺收藏 编辑:程序博客网 时间:2024/04/29 12:14
package com.bwie.zhangyabo;import android.app.Activity;import android.os.Build;import android.view.View;import android.view.ViewGroup;import android.view.Window;import android.view.WindowManager;/** * User: * Date: 2017-12-05 16:30 * Description:沉浸式工具类 */public class chenjinshi { /** * 利用反射获取状态栏高度 * @return */ private static int getStatusBarHeight(Activity con) { int result = 0; //获取状态栏高度的资源id int resourceId = con.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = con.getResources().getDimensionPixelSize(resourceId); } return result; } public static void initWindows(Activity context) { Window window = context.getWindow(); int color = context.getResources().getColor(R.color.holo_gray_bright);//此处可修改为你想看到的颜色 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //设置状态栏颜色 window.setStatusBarColor(color); //设置导航栏颜色 window.setNavigationBarColor(color); ViewGroup contentView = ((ViewGroup) context.findViewById(android.R.id.content)); View childAt = contentView.getChildAt(0); if (childAt != null) { childAt.setFitsSystemWindows(true); } } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //透明状态栏 window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //透明导航栏 window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); //设置contentview为fitsSystemWindows ViewGroup contentView = (ViewGroup)context.findViewById(android.R.id.content); View childAt = contentView.getChildAt(0); if (childAt != null) { childAt.setFitsSystemWindows(true); } //给statusbar着色 View view = new View(context); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(context))); view.setBackgroundColor(color); contentView.addView(view); } }}
阅读全文
0 0
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- 沉浸式
- Android 沉浸式 完全沉浸
- java使用spring配置jedis及jedis测试
- 用python通过结巴分词对语料库进行分词初步实现word2vec
- 虚幻4项目里面的灯光
- 传送机制以及ACK机制详解
- CentOS安装桌面
- 沉浸式
- 自己搭建IntelliJ IDEA授权服务器
- 在文件第一列前加入 一列字符串
- bootstrap的属性contentType
- C# gif添加水印
- 啃算法:归并排序及JavaScript实现
- python 之 super函数学习
- 可拖拽悬浮窗、对话框悬浮窗的简单实现
- 公司 集群 饭 强 指令