Reputation: 264
I would like to add those buttons under a drawer menu
those are my xml files:
(layout/activity_main)
<?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" />
</android.support.v4.widget.DrawerLayout>
(menu/activity_main_drawer)
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group
android:checkableBehavior="single">
<item
android:id="@+id/nav_log"
android:title="Log-in" />
<item
android:id="@+id/nav_preferiti"
android:title="Preferiti" />
<item
android:id="@+id/nav_maps"
android:title="Mappa" />
<item
android:id="@+id/nav_terms"
android:title="Termini e condizioni" />
<item
android:id="@+id/nav_who"
android:title="Chi Siamo" />
<item
android:id="@+id/nav_settings"
android:title="Impostazioni" />
<item
android:id="@+id/nav_tutorial"
android:title="Tutorial" />
</group>
</menu>
I tried to use a linearlayout with gravity bottom (or end) but it remained at the top
Upvotes: 8
Views: 5197
Reputation: 1433
Try this!
In your menu/activity_main_drawer
Add the following after the group
<item android:title="">
<menu>
<item
android:id="@+id/nav_about_us"
android:title="Follow us:"
app:actionLayout="@layout/share"
app:showAsAction="ifRoom"/>
</menu>
</item>
and your_custom_layout.xml may be like
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical"
android:background="@color/colorPrimaryDark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/right_arrow"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/right_arrow"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/right_arrow"/>
</LinearLayout>
</LinearLayout>
Upvotes: 2
Reputation: 6761
Try to place additional views inside your NavigationView
, something like:
<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">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<!--Here is a container at the bottom of navigation drawer. Place your images here-->
</LinearLayout>
</RelativeLayout>
</android.support.design.widget.NavigationView>
Upvotes: 8