2016-04-28 3 views
0

Извините, мой плохой английский.Ошибка с панелью инструментов

У меня есть следующий файл "activity_main.xml", проблема в том, что панель инструментов НЕ появляется, кто-то говорит мне, как заставить ее выглядеть?

<android.support.v4.widget.DrawerLayout 
android:id="@+id/drawer_layout" 
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" 
> 

<RelativeLayout 
android:id="@+id/anchor_point" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

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

</RelativeLayout> 

<android.support.design.widget.NavigationView 
android:id="@+id/navigation" 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:layout_gravity="start" 
app:elevation="4dp" 
app:headerLayout="@layout/drawer_header" 
app:menu="@menu/menu_main"/> 
</android.support.v4.widget.DrawerLayout> 

с этим другим "activity_main.xml" панели инструментов появляется, но не хватает панели навигации

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res /android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:ads="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

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

<RelativeLayout 
    android:layout_below="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/container"> 
</RelativeLayout> 

</RelativeLayout> 
+0

попробуйте добавить эту строку в navigationview в вашем activity_main xml 'android: layout_below = "@ + id/toolbar"' .. дайте мне знать дальше .. –

ответ

1

Try таким образом он будет работать

<LinearLayout 
    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:fitsSystemWindows="true" 
    android:orientation="vertical"> 

    <android.support.v7.widget.Toolbar 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/abc_action_bar_default_height_material" 
    android:background="?attr/colorPrimary" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/> 

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

    <!-- Real content goes here --> 
    <FrameLayout 
     android:id="@+id/content" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

    <!-- The navigation drawer --> 
    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:menu="@menu/drawer"/> 

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