2016-05-03 24 views
0

私は完璧に動作するナビゲーションドロワーを持っていますが、ナビゲーションメニューを1つ選択すると(下の画像を参照してください)、ツールバーの上にビューが追加されます。Androidのツールバーの上に表示

the view added on top

はここに私の引き出しのxml

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> 



    <item android:title="My Dashboard" 
      android:id="@+id/nav_item_home" 
      android:icon="@drawable/ic_home"/> 

    <item android:title="Random Check" 
     android:id="@+id/nav_item_random_check" 
     android:icon="@drawable/random_check"/> 

    <item android:title="Verify Reference" 
      android:id="@+id/nav_item_verify_receipt" 
      android:icon="@drawable/verify_receipts"/> 

    <item android:title=" Meter Reading" 
      android:id="@+id/nav_item_meter_reading" 
      android:icon="@drawable/meter_reading"/> 

    <group android:id="@+id/group_settings_id"> 
     <item android:title="Help" 
      android:id="@+id/nav_item_help" 
      android:icon="@drawable/help"/> 
    </group> 
     <item android:title="Logout" 
      android:id="@+id/nav_item_logout" 
      android:icon="@drawable/logout"/> 



</menu> 

主な活動xmlです:

は、ここに私のフラグメントレイアウト

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

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="false"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/randomCheckDescription" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="40dp" 
      android:layout_marginTop="30dp" 
      android:gravity="center" 
      android:text="This scans the barcode of any existing business" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp" /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:layout_marginTop="10dp"> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.3" 
       android:orientation="horizontal"> 

       <EditText 
        android:id="@+id/txtRandomCheckBacode" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:textSize="12dp" 
        android:inputType="text" 
        android:hint="barcode" 
        android:textColorHint="@color/edit_text_hint" 
        android:textColor="@color/edit_text" 
        android:paddingLeft="10dp" 
        android:paddingBottom="10dp" 
        android:background="@drawable/edit_text_bottom_border" 
        android:layout_marginLeft="20dp" /> 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="0.7" 
       android:orientation="horizontal" 
       android:weightSum="1"> 

       <ImageButton 
        android:id="@+id/btnScanBarcode" 
        android:layout_width="fill_parent" 
        android:layout_height="28dp" 
        android:text="@string/scan_hint" 
        android:layout_marginRight="20dp" 
        android:background="@color/white" 
        android:textColor="@color/white" 
        android:layout_marginLeft="2dp" 
        android:src="@drawable/ic_scan" 
        android:contentDescription="@string/scan_hover" /> 

      </LinearLayout> 

     </LinearLayout> 

     <android.support.v7.widget.AppCompatButton 
      android:id="@+id/btnRandomCheckSubmit" 
      android:layout_width="fill_parent" 
      android:layout_height="35dp" 
      android:layout_marginTop="80dp" 
      android:text="Proceed" 
      android:background="@drawable/custom_button" 
      android:layout_marginLeft="20dp" 
      android:layout_marginRight="20dp" 
      android:textColor="@color/white" 
      android:foreground="?android:selectableItemBackground" /> 

    </LinearLayout> 
</ScrollView> </LinearLayout> 

イメージです。

<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="wrap_content" 
     android:background="@color/menu_bar_color" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:title="@string/app_name" /> 

    <android.support.v4.widget.DrawerLayout 

     android:id="@+id/drawerLayout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 


     <FrameLayout 
      android:id="@+id/containerView" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical"></FrameLayout> 


     <android.support.design.widget.NavigationView 

      android:id="@+id/shitstuff" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      app:headerLayout="@layout/header" 
      app:itemTextColor="@color/dark_grey" 
      app:menu="@menu/drawermenu" /> 

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

</LinearLayout> 
+0

は – Kushal

+0

おかげであなたはNavigationViewを実装するあなたの.xmlコードを共有ねえ、私が求めていますあなたがandroid.support.design.widget.NavigationViewを使用したレイアウト.xmlコード – Innocent

+0

...あなたのフィードバックのための – Kushal

答えて

0
<?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:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <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/base_toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       app:popupTheme="@style/AppTheme.PopupOverlay" /> 

     </android.support.design.widget.AppBarLayout> 

     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"></FrameLayout> 

    </LinearLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header_main" 
     app:itemIconTint="@color/colorPrimary" 
     app:menu="@menu/navigation_menu_item" /> 

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

style.xmlは以下の通りです:

<resources> 

    <!-- Base application theme. --> 
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
     <!-- Customize your theme here. --> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 

    <style name="AppTheme.NoActionBar"> 
     <item name="windowActionBar">false</item> 
     <item name="windowNoTitle">true</item> 
    </style> 

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

</resources> 
関連する問題