1

so I'm trying to have a translucent statusbar and navbar, where the status bar gets it's color from the toolbar and the navbar gets its color from the content being display underneat it.

Like this:

enter image description here

This however was made possible with some hackery:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >

        <View
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:background="@drawable/alt_grad"
            />

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:fitsSystemWindows="true"
            ...
            />

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

        <android.support.v4.view.ViewPager
            ...
            />

    </RelativeLayout>

    ...

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

Notice the transparent toolbar and tablayout with the 300dp height view not respecting fitSystemWindows painting under then with the gradient.

Without this type of hackery this is as far as I can get to:

enter image description here

<android.support.v4.widget.DrawerLayout
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/alt_grad"
        android:fitsSystemWindows="true"
        >

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:fitsSystemWindows="true"
            />

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

        <android.support.v4.view.ViewPager
            ...
            />

    </RelativeLayout>

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

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

Any ideas on how i can manage to do this? Thanks!

Edric
  • 24,639
  • 13
  • 81
  • 91
Andre Romano
  • 1,004
  • 11
  • 20

0 Answers0