沉浸式状态栏的两种表现形态
来源:互联网 发布:java 判断是不是汉字 编辑:程序博客网 时间:2024/03/29 19:49
1、状态栏显示在图片的上面,如图所示:
实现方法:重写Activty:onWindowFocusChanged()
(1) 适用于首页,刚运行程序时,状态栏悬浮在首页的上面
int option=View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |View.SYSTEM_UI_FLAG_LAYOUT_STABLE |View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
(2) 适用于全屏显示,例如视频播放(横屏)
int option = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
@Override public void onWindowFocusChanged(boolean hasFocus) { super.onWindowFocusChanged(hasFocus); if (hasFocus && Build.VERSION.SDK_INT >= 19) { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); View decorView = getWindow().getDecorView(); decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } }
2、状态栏与布局垂直排布,互不遮挡。如图:
实现方法:
layout布局文件:根布局设置fitsSystemWindows属性为true
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.xl.test.activity.MainActivity" android:fitsSystemWindows="true"> <include layout="@layout/commont_toobar" /></LinearLayout>
values/styles.xml:
<resources><style name="ColorTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar"/></resources>
values-v19/styles.xml:
<resources><style name="ColorTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowTranslucentStatus">false</item> <item name="android:windowTranslucentNavigation">true</item> </style></resources>
values-v21/styles.xml:statusBarColor 颜色与主题颜色一致
<resources><style name="ColorTranslucentTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="windowActionBar">false</item> <item name="android:windowTranslucentStatus">false</item> <item name="android:windowTranslucentNavigation">true</item> <item name="android:statusBarColor">@color/dividerColor</item> </style></resources>
AndroidManitest.xml: 设置Theme属性
<activity android:name=".activity.MainActivity" android:theme="@style/ColorTranslucentTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
原文链接:http://blog.csdn.net/lizhiying61f/article/details/52213585
http://blog.csdn.net/guolin_blog/article/details/51763825
阅读全文
0 0
- 沉浸式状态栏的两种表现形态
- android 沉浸式状态栏的两种实现方式
- 【Android】沉浸式状态栏的两种实现方式
- Android沉浸式状态栏的两种实现方式
- Fragment和Activity两种沉浸式状态栏的实现
- 两种常见的沉浸式状态栏(透明系统状态栏)全解析
- 另外两种android沉浸式状态栏实现思路
- 沉浸式状态栏的实现;
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- 沉浸式状态栏的使用
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- 沉浸式状态栏的设置
- 真正的沉浸式状态栏
- 沉浸式状态栏的实现
- 沉浸式状态栏的实现
- 所谓的沉浸式状态栏---
- OpenCV局部坐标系和世界坐标系转换
- 【笔记】常用 API的基本知识以及常用方法
- Redis数据结构详解之List(二)
- 用java程序给自己qq邮箱发邮件
- HTTP响应头和请求头信息对照表
- 沉浸式状态栏的两种表现形态
- mybatils自学教程
- Android零基础入门第55节:ImageSwitcher和TextSwitcher使用
- python os 命令,及判断文件夹是否存在
- python-opencv中的cv2.inRange函数
- HDU 3932(计算几何+最小圆覆盖)
- 404. Sum of Left Leaves
- python __add__和__radd__
- centos7 安装 mysql