0

I have a material design navigation drawer i created from this tutorial.

It works perfect with toolbar and all. I can click on an item in the drawer and the respective fragment is displayed plus the title.

However i would like to make the toolbar on one fragment to be transparent so that the background image is displayed like in the image below: enter image description here

PROBLEM: My problem is the fragment doesnt seem to start over the toolbar but below it.This is the result:enter image description here

I dont know how to fix this.Any suggestions will be welcomed.

Steve Kamau
  • 2,755
  • 10
  • 42
  • 73

1 Answers1

0

Use this for toolbar.xml:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/toolbar_image"/>

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

</FrameLayout>

Of course, you'll need to change "@drawable/toolbar_image" to the drawable that you want to use for the background image.

kris larson
  • 30,387
  • 5
  • 62
  • 74