android5.x以上 状态栏透明的问题
1、先在style中把 statusBarColor 设置为透明 如下
<item name="android:statusBarColor">@android:color/transparent</item>
2、使用material design的页面中,使全屏显示
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
3、针对本人自己的情况,我是在toolbar的上面放了一张图片,默认图片会显示在状态栏下面,此时在imageview外套一个framelayout设置
android:fitsSystemWindows为true,图片就会全屏显示,压在状态栏下面。
/此时需要给toolbar设置一个状态栏高度的 margin值,否则,会使toolbar跟状态栏重叠,toolbar中的文字显示不全。因为5.0新特性,当toolbar向上移动时,会默认显示在状态栏的下面
我们做了全屏显示的设置后,toolbar就会跟状态栏重叠。此时可以设置toolbar的margintop为 状态栏高度(6.0为24dp 以下为25dp)
<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout 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.chuangyuan.qdocument.activity.AboutActivity"> <android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<FrameLayout //外面套上framelayout并设置
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="230dp"
android:src="@drawable/head"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
/> </FrameLayout> <android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
android:background="@android:color/transparent"
android:layout_marginTop="24dp" //此时需要给toolbar设置一个状态栏高度的 margin值,否则,会使toolbar中的文字显示不全。
/>
</android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout> <android.support.v4.widget.NestedScrollView
android:id="@+id/nested"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
> <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="a。。。代表很多字" /> </LinearLayout>
</android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout>
android5.x以上 状态栏透明的问题的更多相关文章
- Android沉浸式状态栏(透明状态栏)最佳实现
Android沉浸式状态栏(透明状态栏)最佳实现 在Android4.4之前,我们的应用没法改变手机的状态栏颜色,当我们打开应用时,会出现上图中左侧的画面,在屏幕的顶部有一条黑色的状态栏,和应用的风格 ...
- Android状态栏透明(沉浸式效果)
Android状态栏透明(沉浸式效果) 默认效果 沉浸式效果 方式一 源码 下载地址(Android Studio工程):http://download.csdn.net/detail/q487880 ...
- android5.1 隐藏状态栏
修改frameworks/base/core/res/res/values/dimens.xml文件中 <!-- Height of the status bar --> <!-- ...
- android中状态栏透明
设置 Acitivity 所在 window 的属性 @Override protected void onCreate(Bundle savedInstanceState) { super.onCr ...
- apicloud 顶部状态栏透明方法
api.setStatusBarStyle({ style: 'dark', color:'transparent' });
- iOS平台设置系统状态栏(通知栏、顶部状态栏)样式背景颜色或透明
5+App开发 状态栏 配置系统状态栏样式 iOS平台可支持对系统状态栏样式的配置,在应用manifest.json文件的plus->distribute->apple下添加UIStatu ...
- [置顶]
Xamarin android沉浸式状态栏
虽然关于android "沉浸式"状态栏有很多博客介绍过,从小菜到大神无一例外.我第一次看到这种"沉浸"式的效果我也以为真的是这么叫,然而根本不是这么回事,完全 ...
- HBuilder设置APP状态栏
一. 前言 状态栏就是手机屏幕最顶部的区域,包括了:信号.运营商.电量等信息.通常APP都有属于自己的色调风格,为了达到整体视觉美观,通常会设置状态栏和标题栏的色调设置成一致. 图例: 二.状态栏状态 ...
- Android修改状态栏颜色全方位教程
关键字:状态栏着色 透明状态栏 沉浸式 白底黑字 Github Demo:https://github.com/imflyn/Eyes 参考文章: Android-transulcent-status ...
随机推荐
- nsstring字符串重组
// // main.m // 05-字符串重组 // // Created by apple on 14-3-20. // Copyright (c) 2014年 apple. All ri ...
- C#并发处理-锁OR线程安全?
每次写博客,第一句话都是这样的:程序员很苦逼,除了会写程序,还得会写博客! 当然,题外话说多了,咱进入正题! 背景 基于任务的程序设计.命令式数据并行和任务并行都要求能够支持并发更新的数组.列表和集合 ...
- scala学习笔记(1)
下载和安装Scala 前往http://www.scala-lang.org/downloads下载Scala在各个平台的安装包,安装后即可在运行scala编译器和交互式命令行环境(interacti ...
- Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file
springframework.version 3.2.6.RELEASE jdk 1.8
- 《数据结构与算法分析:C语言描述_原书第二版》CH2算法分析_课后习题_部分解答
对于一个初学者来说,作者的Solutions Manual把太多的细节留给了读者,这里尽自己的努力给出部分习题的详解: 不当之处,欢迎指正. 1. 按增长率排列下列函数:N,√2,N1.5,N2,N ...
- Static Const
Static 内部的 Const 不可变的 一般写法 在.m文件中, static NSString *const ID = @"shop"; static const CGFlo ...
- SpringMVC注解@RequestParam全面解析
在SpringMVC后台控制层获取参数的方式主要有两种,一种是request.getParameter("name"),另外一种是用注解@RequestParam直接获取.这里主要 ...
- (转)json+flexgrid+jbox组合运用页面刷新<jsp>
插件效果 1.JSP页面 1 <%@ page language="java" contentType="text/html; charset=UTF-8" ...
- html 标签内部元素上下居中
<div style="width: 200px; height: 200px; border: 1px solid red; line-height: 200px;"> ...
- Spring中Bean的配置:基于XML文件的方式
Bean的配置一共有两种方式:一种是基于XML文件的方式,另一种是基于注解的方式.本文主要介绍基于XML文件的方式 <bean id="helloWorld" class=& ...