简体   繁体   中英

Android draw status bar

So I'm trying to get my app drawing under the status bar. Not quite sure how to achieve this though...

Current layout XML:

<LinearLayout 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"
android:fitsSystemWindows="true"
android:orientation="horizontal"
tools:context=".activity.CharacterActivity">

<ImageView
    android:id="@+id/img_header"
    android:layout_width="@dimen/nav_drawer_width"
    android:layout_height="match_parent"
    android:scaleType="centerCrop" />

<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"
    android:fitsSystemWindows="true"
    tools:context=".activity.CharacterActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"/>

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

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

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

The style used for the layout:

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

A screenshot of what I'm getting: 我有什么

And a quickly edited screenshot of what I want to be getting: 我想要的是

Any suggestions or pointers would be fantastic!

Well I've just discovered how to do almost exactly what I wanted to. All I had to do was remove the android:fitsSystemWindows="true" attribute and all worked out fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM