-3

I want make a map APP and I used Drawerlayout,my main layout is a Relativelayout and left drawer is a Linerlayout, my layout is as bellow.

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:id="@+id/fragment_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">



    <com.esri.arcgisruntime.mapping.view.MapView
        android:id="@+id/main_map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"></com.esri.arcgisruntime.mapping.view.MapView>
    <!--SearchBar部分-->
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal" android:layout_width="500dp"
        android:layout_height="50dp"
        android:layout_marginTop="20dp"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_marginLeft="20dp">

        <ImageButton
            android:id="@+id/searchbar_more_button"
            android:layout_width="50dp"
            android:layout_height="match_parent"
            android:src="@drawable/main_searchbar_more"
            android:background="@color/mainColor"
            android:scaleType="centerInside"/>

        <EditText
            android:id="@+id/searchbar_searchtext_textview"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@color/whiteColor"
            android:gravity="center"
            android:hint="请输入要查询的信息"
            android:textAlignment="viewStart"
            android:textSize="20dp" />
        <ImageButton
            android:paddingTop="5dp"
            android:paddingBottom="5dp"
            android:id="@+id/searchbar_search_button"
            android:layout_width="50dp"
            android:layout_height="match_parent"
            android:background="@color/mainColor"
            android:src="@drawable/main_searchbar_search"
            android:scaleType="centerInside"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="40dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_marginTop="70dp"
        android:layout_marginRight="20dp">

        <ImageButton
            android:id="@+id/main_global_button"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:scaleType="centerInside"
            android:background="@color/mainColor"
            android:src="@drawable/main_global_button" />

        <ImageButton
            android:id="@+id/main_layerswitch_button"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginTop="20dp"
            android:scaleType="centerInside"
            android:background="@color/mainColor"
            android:src="@drawable/main_layerswitch_button" />

        <ImageButton
            android:id="@+id/main_electricity_button"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginTop="20dp"
            android:scaleType="centerInside"
            android:background="@color/mainColor"
            android:src="@drawable/main_electricity_button" />

        <ImageButton
            android:id="@+id/main_measure_button"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginTop="20dp"
            android:background="@color/mainColor"
            android:scaleType="centerInside"
            android:src="@drawable/main_measure_button" />

        <ImageButton
            android:id="@+id/main_location_button"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:layout_marginTop="20dp"
            android:background="@color/mainColor"
            android:scaleType="centerInside"
            android:src="@drawable/main_location_button" />
    </LinearLayout>


</RelativeLayout>
<!--左边抽屉菜单-->
<LinearLayout
    android:id="@+id/menu_layout_left"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    android:orientation="vertical">
    <include layout="@layout/left_drawer"></include>
</LinearLayout>

But I find that although I set the drawer's height as 'match_parent', it's height is depended on searchbar and image button's height,when I run the code on my tablet,the result is like this: wrong height drawer picture You can see that the drawer's height is wrong. Is there anyone know the reason? Thanks very much.

Onik
  • 19,396
  • 14
  • 68
  • 91

2 Answers2

0

FOR THE nav drawer you should use it like this

<?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/content_main_layout"
        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"
        android:background="@color/backGroundColor"
        app:menu="@menu/menu_activity_drawer"
        app:itemTextColor="@color/mainFontColor"

        />


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

so you should not use linear layout inside the drawer put what ever items you want you can put menu item or you can put recyclerview

  • I tried it but it also didn't work. I checked the Information and knew that you could use other layout without NavigationView inside the drawer. Thanks for your replay. – Meteor.Chen Aug 13 '18 at 02:52
0

I cant't find the reason of this question.Maybe it's a bug of ArcGIS Runtime for Android or Android SDK, but I have thought a solution of it. I used a popupWindow instand of DrawerLayout. If there is anyone meet the same question, you can solve with this way. Thanks your help.