Android4.4系统以上实现沉浸式状态栏
来源:互联网 发布:网络文件传输协议 编辑:程序博客网 时间:2024/06/06 05:36
1.在页面中判断系统是否是4.4以上的
//判断当前SDK版本号,如果是4.4以上,就是支持沉浸式状态栏的 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); }
2.将Activity的主题设置为NoActionBar
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> </style>
3.修改布局文件,测试效果
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="true" android:fitsSystemWindows="true" android:background="#6699ff" android:orientation="vertical" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="50dp" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="20sp" android:layout_centerInParent="true" android:textColor="#ffffff" android:text="标题" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:paddingLeft="20dp" android:paddingRight="20dp" android:textSize="16sp" android:textColor="#ffffff" android:text="返回" android:background="#00000000" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:paddingLeft="20dp" android:paddingRight="20dp" android:textSize="16sp" android:textColor="#ffffff" android:text="设置" android:background="#00000000" /> </RelativeLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffffff" android:orientation="vertical" android:gravity="center" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="28sp" android:textColor="#000000" android:text="Hello World" android:textStyle="italic" /> </LinearLayout></LinearLayout>
4.Android4.4.4系统实现的效果
0 0
- Android4.4系统以上实现沉浸式状态栏
- Android4.4以上实现沉浸式状态栏
- 沉浸式状态栏(Android4.4及以上)
- Android4.4以上沉浸式状态栏
- android4.4~6.0以上沉浸式实现
- Android4.4以上实现沉浸式状态栏 及 低版本中使用Material设计
- Android4.4 实现沉浸式状态栏
- Android4.4实现状态栏沉浸
- Android 5.0及以上系统实现沉浸式状态栏
- 完美兼容4.4及以上系统实现沉浸式状态栏
- 实现android4.4新特性:沉浸式状态栏
- 关于Android4.4以后沉浸式自定义状态栏实现
- Android KITKAT 以上实现沉浸式状态栏
- Android KITKAT 以上实现沉浸式状态栏
- Android KITKAT 以上实现沉浸式状态栏
- Android KITKAT 以上实现沉浸式状态栏
- 首页增加沉浸式状态栏,仅支持android4.4及以上
- coordinatelayout android:fitsSystemWindows 沉浸式状态栏在android4.4 和 4.4以上版本的坑
- 设计模式-单例模式
- Linux常用命令-crontab:
- sigsuspend的理解
- freeswitch 媒体早期协商模式分析
- 2-21 多线程同步编程
- Android4.4系统以上实现沉浸式状态栏
- C/C++ 校招面试知识点记录
- webview 调起微信支付
- 机器学习--从0开始
- MarkDown的基本使用
- 树莓派——小学生都可以成为极客
- Android实现全屏显示的方法
- MySQL-InnoDB Compact 行记录格式
- Java并发volatile理解