zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    BZOJ-1206 虚拟内存 Hash+离散化+Priority_Queue
    BZOJ-2324 营救皮卡丘 最小费用可行流+拆下界+Floyd预处理
    BZOJ-1834 网络扩容 最小费用最大流+最大流+乱搞
    学习笔记 --- 最小费用最大流
    BZOJ-1927 星际竞速 最小费用最大流+拆点+不坑建图
    BZOJ-1070 修车 最小费用最大流+拆点+略坑建图
    BZOJ-1207 打鼹鼠 DP(LIS)
    BZOJ-2756 奇怪的游戏 黑白染色+最大流+当前弧优化+二分判断+分类讨论
    BZOJ-1189 紧急疏散evacuate BFS预处理+最大流+二分判定+神建模!!
    BZOJ-1822 Frozen Nova 冷冻波 计(jie)算(xi)几何+二分+最大流判定+经典建图
  • 原文地址:https://www.cnblogs.com/epmouse/p/5483723.html
Copyright © 2011-2022 走看看