AnsweredAssumed Answered

A layout bug of MapView

Question asked by MeteorChenBo on Aug 14, 2018

I want make a map APP and I used Drawerlayout, and my main layout is a Relativelayout and left drawer is a Linerlayout. My main 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 left 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

You can see that the drawer's height is wrong.When I replaced the MapView with a LinerLayout,  the height was right. Is there anyone know the reason? Thanks very much.

Outcomes