I have a scroll view inside which there is a relative layout containing a flexible sized content on top and a map view below it. If the entire content's height is smaller than the screen view port (Scroll View), I wanted the map view to fill the remaining space below. If the entire content is larger than screen view port then I wanted the map view to have at least a certain height. This is a stripped version of what I have done.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/flexContent"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentTop="true"
android:background="#086dd9"
android:gravity="center"
android:text="Flexible content here"
android:textColor="@android:color/white"
android:textSize="22sp" />
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@id/flexContent"
android:background="#f73f3f"
android:minHeight="120dp"
map:mapType="normal"
tools:ignore="MissingPrefix" />
</RelativeLayout>
</ScrollView>
It works as expected when the entire content's height is smaller than the screen view port's height (Scroll view's height). However, when it is not, everything works good except the map is not loading to the mapview's full height. Please take a look at the images below
Content smaller than scroll view
Content larger than scrollview
As you can see in the second picture, the map view itself is respecting the minHeight 120dp constraint set in the layout (I have made the background of the map view red) but the actual map is not loading to its full height.
How can this be fixed?