imnotfromrussia imnotfromrussia - 8 days ago 5
Android Question

Side menu does not extend

I try to do the side menu that slides out from the left side.
I use a few guides, but my menu does not come out, but is immediately visible on the home screen.

The guides, when the side menu was at the center of the screen instead of the left side just added this line:

android:layout_gravity="start"


but in my application it does not work ...

My
activity_maps.xml


<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">





<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3">

<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
tools:context="ru.marks.mygps1.MapsActivity"
android:layout_weight="1"
android:layout_height="match_parent" />
</LinearLayout>

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp">

<Button
android:text="but1"
android:id="@+id/B1"
android:layout_height="match_parent"
android:layout_width="match_parent" />


</LinearLayout>



<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"

app:menu="@menu/navigation_menu"
android:layout_gravity="start" >


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


</LinearLayout>


My
navigation_menu.xml


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


<item android:id="@+id/button1"
android:title="Button 1" />
<item android:id="@+id/button2"
android:title="Button 2" />
<item android:id="@+id/button3"
android:title="Button 3" />

</menu>


I can not fix it, help.

edit:


before adding the side menu

after

I would like to make this menu was coming out of the left side

Code with my side:

<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"

app:menu="@menu/navigation_menu"
android:layout_gravity="start" >


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

Answer
  • orientation = horizontal (width: 0dp , Height:choice , weight: any >1 )
  • orientation = vertical (width: choice , Height:0dp , weight: any >1 )

OR Try Android Default Drawer Layout