kanytu / android-material-drawer-template

An Android template with navigation drawer for material design
Apache License 2.0
674 stars 217 forks source link

Navigation drawer bottom item #39

Closed sameera26 closed 9 years ago

sameera26 commented 9 years ago

I have successfully integrated material navigation drawer. My problem is i want to add bottom item in the navigation drawer. Can you guid me to achieve this. Thanks!

kanytu commented 9 years ago

For that you need to add the items aligned bottom and make the your navigation drawer list end at the items. Here is an example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/linearLayout"/>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentBottom="true"
        android:id="@+id/linearLayout">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Text"
            android:id="@+id/textView"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="New Text"
            android:id="@+id/textView2"/>
    </LinearLayout>
</RelativeLayout>

Notice the list: android:layout_above="@+id/linearLayout" which is above the linearlayout containing the bottom items. Hence the android:layout_alignParentBottom="true" on the layout

sameera26 commented 9 years ago

Thanks for the quick response. I added button to the fragment_navigation_drawer.xml and solved my problem. Cheers!

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start"

<android.support.v7.widget.RecyclerView
    android:id="@+id/drawerList"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:clickable="true"
    android:focusableInTouchMode="true"
    android:scrollbars="vertical"
    android:focusable="true"
    android:fitsSystemWindows="true"
    android:layout_height="match_parent"
    android:background="@color/myDrawerBackground"/>

<Button
    android:id="@+id/button2"
    android:layout_height="50dp"
    android:text = "Logout"
    android:layout_width="match_parent"
    android:layout_alignParentBottom="true"/>