0

Q: How do I make the system bar be the correct color?

I've tried setting this up following the cheesesquare sample app.

When doing that, they use a coordinator layout and an appbar layout which contains a toolbar layout -- it looks like this: Weather Detail With Appbar and coordinator layout

Then I tried removign the coordinator layout, and app bar, and just have a LinearLayout with a toolbar and a nested scroll view inside it -- looks like this:

Weather Detail Without Appbar

As you can probably tell it doesn't look like quite right. Using their nav drawer layout worked perfectly fine with the status bar being the same color as the toolbar.

I've also tried messing with fitsSystemWindows to no avail.

Q: How do I make the system bar be the correct color?

I think I heard about this potentially being a bug in the design library, so perhaps there is a workaround for now?

Here is my layout code:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

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

</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/fixed_scroll_behavior">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingTop="24dp">

        <android.support.v7.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/card_margin">

            <LinearLayout
                style="@style/Widget.CardContent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Info"
                    android:textAppearance="@style/TextAppearance.AppCompat.Title" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="blank text for now" />

            </LinearLayout>

        </android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

Doronz
  • 704
  • 8
  • 21

1 Answers1

0

My style-v21 theme contains:

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

Removing that fixed the problem.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Doronz
  • 704
  • 8
  • 21