soumya sambit Kunda
soumya sambit Kunda

Reputation: 508

Where to place my xml for other layouts?

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/drawer_layout"
    android:fitsSystemWindows="true">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_top"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_bottom"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:background="?attr/colorPrimary"
            android:layout_alignParentBottom="true"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
      </RelativeLayout>
 <android.support.design.widget.NavigationView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:id="@+id/nav_view"
        app:menu="@menu/navmenu"
        app:headerLayout="@layout/header" />
 </android.support.v4.widget.DrawerLayout>

In the above code where should I place my layout codes so that it will not over lap with the toolbars. When I am wrapping the RelativeLayout which contains toolbars with LinearLayout and adding my layout code it is overlapping with the toolbar. So where can I place my layout

<LinearLayout
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/ll">
    <TextView
      android:layout_width="fill_parent"
    android:layout_height="fill_parent"
      android:text="myTextViewTest"/>
  </LinearLayout>

Upvotes: 0

Views: 74

Answers (1)

therealprashant
therealprashant

Reputation: 741

Add an Id for Relative Layout below which you need to place your other layout and then use 'layout_below' and "layout_above" tag to place it. I have added it within the RelativeLayout itself. The code snipet

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_top"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_bottom"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:background="?attr/colorPrimary"
            android:layout_alignParentBottom="true"
            android:minHeight="?attr/actionBarSize"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
        <LinearLayout
            android:layout_below="@id/toolbar_top"
            android:layout_above="@id/toolbar_bottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
                 <TextView
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent"
                     android:text="myTextViewTest"/>
        </LinearLayout>

    </RelativeLayout>

Upvotes: 1

Related Questions