2017-09-30 1 views
1

J'ai essayé d'ajouter un pied de page à un tiroir. Cela fonctionne mais reste fixe et couvre certains éléments du menu. Comment puis-je faire pour avoir le pied de page à la fin de la liste (après le dernier élément). Il prend l'élément de menu à partir d'un xml (activity_main_drawer.xml) et il a une tête (nav_header_main.xml)Pied de défilement dans le tiroir

Le code du tiroir est ceci:

<?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"> 
     <include 
      layout="@layout/app_bar_main" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@drawable/side_nav_bar" 
      android:id="@+id/content_main"/> 
    </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:menu="@menu/activity_main_drawer"> 
     <include layout="@layout/nav_footer_main"></include> 
    </android.support.design.widget.NavigationView> 
</android.support.v4.widget.DrawerLayout> 

le code de pied de page (nav_footer_main.xml)

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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="@dimen/nav_footer_height" 
    android:layout_alignParentBottom="true" 
    android:layout_gravity="bottom" 
    android:background="@drawable/side_nav_bar" 

    android:baselineAligned="false" 
    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:theme="@style/ThemeOverlay.AppCompat.Dark"> 


    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:paddingTop="@dimen/nav_header_vertical_spacing" 
     android:scaleType="centerCrop" 
     app:srcCompat="@mipmap/copyright" 
     tools:ignore="ContentDescription" /> 

    <TextView 
     android:id="@+id/copyright" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/copyright" /> 
</LinearLayout> 

Répondre

0

Selon @Adreamus réponse à la question How to add footer to NavigationView - Android support design library?

que vous pouvez faire par 2 vues de navigation, regardez cette application example on Github

Aussi, je vous suggère d'utiliser MaterialDrawer Library il vous fera économiser beaucoup de temps

enter image description here

+0

Merci beaucoup! – mekki10

+0

@ ligre93 votre frère bienvenue aussi n'hésitez pas à voter et accepter la réponse si cela répond à vos questions, bonne journée –