Androi沉浸式状态栏
来源:互联网 发布:夏普lcd70tx8008a知乎 编辑:程序博客网 时间:2024/06/06 06:42
一.首先得设置主题,当然也可以在每个xml布局里面设置
2.单独设置状态栏的颜色
<style name="Theme.Timetodo" parent="@android:style/Theme.Holo.Light">
<!-- translucent system bars -->
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
在xml设置必须写在最外层的布局当中
android:clipToPadding="true"
android:fitsSystemWindows="true"
<!-- translucent system bars -->
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
在xml设置必须写在最外层的布局当中
android:clipToPadding="true"
android:fitsSystemWindows="true"
二.沉浸式状态栏有两种方式
1.让状态栏和背景颜色相同
public Boolean MyTitle() {
//判断版本是否大于4.4
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
return true;
} else {
return false;
}
}
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
return true;
} else {
return false;
}
}
2.单独设置状态栏的颜色
public static Boolean MyTitle(Activity activity, int iscolor) {
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
SystemBarTintManager tintManager = new SystemBarTintManager(activity);
// 激活状态栏设置
tintManager.setStatusBarTintEnabled(true);
// 激活导航栏设置
tintManager.setNavigationBarTintEnabled(true);
tintManager.setStatusBarTintResource(iscolor);
return true;
} else {
return false;
}
}
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
SystemBarTintManager tintManager = new SystemBarTintManager(activity);
// 激活状态栏设置
tintManager.setStatusBarTintEnabled(true);
// 激活导航栏设置
tintManager.setNavigationBarTintEnabled(true);
tintManager.setStatusBarTintResource(iscolor);
return true;
} else {
return false;
}
}
0 0
- Androi沉浸式状态栏
- Androi沉浸式模式
- 状态栏、沉浸式状态栏
- 沉浸式状态栏/透明状态栏
- 透明状态栏(沉浸式状态栏)
- Android 沉浸式状态栏
- 沉浸式状态栏
- android 沉浸式 状态栏
- android 沉浸式状态栏
- android沉浸式状态栏
- 沉浸式状态栏
- Android沉浸式状态栏
- Android 沉浸式状态栏
- 沉浸式状态栏
- 沉浸式状态栏
- android 沉浸式状态栏
- Android沉浸式状态栏
- 设置沉浸式状态栏
- 在Mac OS X上安装 Ruby运行环境
- spring mvc接受前端投递的json问题
- Android webview加载本地html实现跨域访问
- Linux系统dev/目录下的tty
- Android 系统默认音量和最大音量
- Androi沉浸式状态栏
- 基于Zookeeper的Spark HA配置说明
- gson引用泛型解析
- http,https区别
- MVC 与 MVVM 设计架构简介
- 你会写软件开发文档吗?
- http请求头和响应体信息
- 软工文档总结
- STM32串口一直进中断解决方法