AppBar不会重叠状态栏

AppBar不会重叠状态栏

本文介绍了使用CollapsingToolbarLayout时,AppBar不会重叠状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望AppBarStatusBar重叠. AppBar具有图像作为背景,我希望该图像与状态栏重叠,但是当我使用CollapsingToolbarLayout时,StatusBar变白并且图像在StatusBar以下:

I want AppBar to overlap StatusBar. AppBar has image as background and I want this image to overlap statusbar, but when I use CollapsingToolbarLayout StatusBar gets white and image is below StatusBar:

我想要这样的东西:

这里是我的代码:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="218dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true"
        >

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/main.collapsing"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp"
            app:titleEnabled="false"
            >

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                app:layout_collapseMode="parallax"
                android:src="@mipmap/mount"/>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin"
                />

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <include layout="@layout/content_sign_up"/>

    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

推荐答案

获取文件夹并设置主题..

Take a folder and set the theme..

主要主题位于values/styles.xml

 <resources>


    <style name="BaseTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorControlHighlight">@color/accent_translucent</item>
    <item name="colorAccent">@color/accent</item>


    </style>

</resources>

res/values-v21/styles.xml

  <resources>

       <style name="AppTheme" parent="BaseTheme">

       <item name="android:colorControlHighlight">@color/accent_translucent</item>


       <item name="android:windowSharedElementsUseOverlay">false</item>


        <item name="android:statusBarColor">@android:color/transparent</item>

       </style>

       </resources>
  <item name="android:windowTranslucentStatus">true</item>

此处显示的示例通过此操作,我将删除此部分并获得结果

Example shown here By this I am Remove this part and get result

按照示例执行您的要求

https://github.com/antoniolg/MaterializeYourApp

喜欢结果

这篇关于使用CollapsingToolbarLayout时,AppBar不会重叠状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:36