<!-- A DrawerLayout is intended to be used as the top-level content view using match_parent for both width and height to consume the full space available. -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".main_drawer">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:background="@color/octo"/>
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
If you're not building against API 17 or higher, use
android:layout_gravity="left" instead. -->
<!-- The drawer is given a fixed width in dp and extends the full height of
the container. -->
<fragment android:id="@+id/navigation_drawer"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:name="am.octogr.app.octocopy.NavigationDrawerFragment"
tools:layout="@layout/main_drawer_listview" />
</android.support.v4.widget.DrawerLayout>
Hi, how can I put a Toolbar within this layout? This layout for Navigation Drawer. I've tried some code but still not working. 1. Under FrameLayout: Toolbar did not appear. 2. Below FrameLayout: Toolbar appear but content did not display. 3. Have DrawerLayout in a LinearLayout but my fragment seems didn't work well. Thank you in advance.
Let me try to explain.
Android draws View
s from top to down so; A-B-C- are you 3 respective Views in your DrawerLayout
. now A being the Toolbar
is drawn first with params width
fit-to-the-overallwidth and height
fit the content itself, B is drawn with width
fit-to-the-overallwidth and height
fit-to-the-overallheight, etc etc. that means your FrameLayout is drawn second in the drawing successions and on top of your Toolbar
but since its covered you do not see that it is there, if you bring it below, your Toolbar is drawn second in succession hence you see it.
i hope you can deduct a solution from it now.