2017-10-27 6 views
2

ナビゲーション・ドロワーをツールバーの下に収める方法は、メイン・レイアウトと重なります。
activity_set_main.xmlナビゲーション・ドロワーをツールバーの下に置くことができません

<?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" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start" 
    > 

<include 
    layout="@layout/app_bar_set_main" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    /> 

<android.support.design.widget.NavigationView 
    android:id="@+id/nav_view" 
    android:layout_width="wrap_content" 
    android:layout_height="match_parent" 
    android:background="#000000" 
    android:layout_marginTop="?android:attr/actionBarSize" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true" 
    app:itemTextColor ="#FFFFFF" 
    app:headerLayout="@layout/nav_header_set_main" 
    app:menu="@menu/activity_set_main" /> 

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

app_bar_set_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.example.pash.icas_nvod.setMain"> 

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="?attr/colorPrimary" 

     > 
     <ImageView 
      android:layout_width="220dp" 
      android:layout_height="40dp" 
      android:src="@drawable/bydesign_logo" 
      android:layout_marginRight="80dp" 
      android:id="@+id/toolbar_title" /> 
    </android.support.v7.widget.Toolbar> 
</android.support.design.widget.AppBarLayout> 

<include layout="@layout/content_set_main" /> 
</android.support.design.widget.CoordinatorLayout> 

content_set_main.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/content_set_main_drawer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:background="#EE7F22" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="com.example.pash.icas_nvod.setMain" 
    > 
    <ProgressBar 
     android:id="@+id/login_progress" 
     style="?android:attr/progressBarStyleLarge" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="8dp" 
     android:visibility="gone" /> 
</RelativeLayout> 

上記の私のxmlファイルには、可能なメイク引き出しFないですされていますそれはツールバーの下にあります。 引き出しのレイアウトはメインレイアウトと重なっています。どのように私はそれを解決する..? 私は多くを検索しましたが、私の問題に関連する回答はありません。事前に感謝します。

答えて

2

DrawerLayoutandroid:layout_below="@+id/app_bar_set_main"を試すことができます。

----- ----- OR

あなたdrawerlayoutのあなたのツールバーを移動しようとすることができます。だから私のプロジェクトでは、私はLinearLayoutをルートレイアウトとして使用しました。私はあなたのコンポーネントを交換しようとしましたが、それが助けてくれることを願っています

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<include 
layout="@layout/app_bar_set_main" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 

/> 

<android.support.v4.widget.DrawerLayout 
android:id="@+id/drawer_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:fitsSystemWindows="true" 
tools:openDrawer="start" 
> 

<android.support.design.widget.NavigationView 
android:id="@+id/nav_view" 
android:layout_below="@+id/app_bar_set_main" //Add this line also. 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:background="#000000" 
android:layout_marginTop="?android:attr/actionBarSize" 
android:layout_gravity="start" 
android:fitsSystemWindows="true" 
app:itemTextColor ="#FFFFFF" 
app:headerLayout="@layout/nav_header_set_main" 
app:menu="@menu/activity_set_main" /> 

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


</LinearLayout> 

編集:また、ツールバーの下に自分の引き出しに合わせてandroid:layout_belowを追加する必要があります。

+0

すぐに感謝してくれてありがとうございました。あなたの答えは私の問題の近くにあります。 – Prashant

+0

私はあなたを助けてうれしいです:) –

関連する問題