This is the layout of my CustomerSearchFragment
.
It has a CoordinatorLayout
with a AppBarLayout
and a ScrollView
with a FrameLayout
inside.
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.CustomerSearchFragment">
<com.google.android.material.appbar.AppBarLayout
android:id="@ id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
<FrameLayout
android:id="@ id/fl_results_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
The FrameLayout
will host CustomerMapResultsFragment
, whose layout is shown below:
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.CustomerMapResultsFragment">
<com.mapbox.maps.MapView
android:id="@ id/map_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Actual Behaviour: the MapView
's heigth is just a bunch of pixels (like 16dp).
Expected behaviour: the MapView
has to fill all the available space from the AppBar to the bottom of the screen.
What am I missing? Thanks.
CodePudding user response:
I solved adding android:fillViewport="true"
In the <ScrollView>
.
CodePudding user response:
Change your coordinator layout to ConstraintLayout like below code.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".fragments.CustomerSearchFragment">
<com.google.android.material.appbar.AppBarLayout
android:id="@ id/appbar"
android:layout_width="match_parent"
app:layout_constraintTop_toTopOf=parent
android:layout_height="wrap_content">
...
</com.google.android.material.appbar.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@ id/appbar"
app:layout_constraintBottom_toBottomOf="parent">
<FrameLayout
android:id="@ id/fl_results_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
This will solve your problem.