2016-06-30 7 views
2

Ich habe eine Navigationsschublade, die mehrere Elemente enthält. Ich habe eine Schaltfläche am unteren Rand der Navigationsleiste hinzugefügt. Das Problem ist, dass in kleinen Bildschirmen die Schaltfläche das letzte Element in der Schublade abdeckt.Wie füge ich etwas Platz unter dem letzten Gegenstand in einer Navigationsschublade hinzu?

Wie kann ich etwas Platz unter dem letzten Element hinzufügen, so dass die Schaltfläche nichts abdecken wird?

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

    <include 
    layout="@layout/app_bar_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

    <android.support.design.widget.NavigationView 
    android:id="@+id/nav_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" > 

    <Button 
     android:id="@+id/remove_ads_button" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:background="@color/red" 
     android:text="@string/remove_ads" 
     android:textColor="@color/white" 
     android:textSize="15sp" /> 

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

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

activity_main_drawer.xml:

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

<group android:checkableBehavior="none"> 
    <item 
     android:id="@+id/action_contact_us" 
     android:icon="@drawable/ic_contact_us" 
     android:title="@string/action_contact_us" /> 
    <item 
     android:id="@+id/action_share" 
     android:icon="@drawable/ic_share_24dp" 
     android:title="@string/action_share" /> 
    <item 
     android:id="@+id/action_rate_us" 
     android:icon="@drawable/ic_rate_us_24dp" 
     android:title="@string/action_rate_us" /> 
    <item 
     android:id="@+id/action_follow_us" 
     android:icon="@drawable/ic_follow_us_24dp" 
     android:title="@string/action_follow_us" /> 
    <item 
     android:id="@+id/action_help" 
     android:icon="@drawable/ic_help_name" 
     android:title="@string/action_help" /> 
    <item 
     android:id="@+id/action_about_us" 
     android:icon="@drawable/ic_info_24dp" 
     android:title="@string/action_about_us" /> 
    <item 
     android:id="@+id/action_settings" 
     android:icon="@drawable/ic_settings_24dp" 
     android:title="@string/action_settings" /> 
</group> 

</menu> 
+0

Siehe http://stackoverflow.com/questions/30543605/how-to-add-footer-to-navigationview-android-support-design-library. – CoolMind

Antwort

0

ich kam mit einer Idee, wie versuchen zu tun es und es hat für mich funktioniert. Was ich tun musste, ist, ein weiteres Element zum Fach hinzuzufügen und es dann zu deaktivieren.

Der Code ist:

<item 
    android:title="" 
    android:enabled="false" > 
</item> 

Sehr einfach und leicht !!!

0

Mai werden Sie so etwas wie dieses

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     tools:openDrawer="start"> 
     <include 
      layout="@layout/app_bar_main" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" /> 
     <android.support.design.widget.NavigationView 
      android:id="@+id/nav_view" 
      android:layout_width="@dimen/nav_drawer_width" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:fitsSystemWindows="true"> 
      <RelativeLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 
       <Button 
        android:id="@+id/remove_ads_button" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:background="@color/red" 
        android:text="@string/remove_ads" 
        android:textColor="@color/white" 
        android:textSize="15sp" /> 
       <ScrollView 
        android:id="@+id/my_scroll_view" 
        android:layout_above="@id/remove_ads_button" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent"> 
        <LinearLayout 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:orientation="vertical" 
         android:paddingBottom="@dimen/padding_10dp"> 

         <include layout="@layout/nav_header_main"/> 

         <TextView 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" 
          android:text="@string/action_contact_us" 
          android:textSize="@dimen/text_30sp" 
          android:drawableRight="@drawable/ic_contact_us" 
          android:drawablePadding="8dp"/> 
          <!--another menu items--> 

        </LinearLayout> 
       </ScrollView> 


      </RelativeLayout> 

     </android.support.design.widget.NavigationView> 
    </android.support.v4.widget.DrawerLayout> 
+0

Dies ist keine gute Lösung. Ich möchte das richtig machen. –

+0

Vielleicht ist dies keine gute Lösung. Aber es funktioniert) – Leonid

+0

Es muss eine bessere Option geben –

Verwandte Themen