0

I am trying to implement bottomNavigationBar together with google Maps. But GoogleMaps takes all the space left and overrides the bottomNavigatonBar. If I define googleMaps height with "dp" or so it only works for one screensize. Is there any way to get BottomNavigationView together with googleMaps so that they fill the screen together?

Thats my actual xml file:

<LinearLayout 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/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".fahrplanmap">

<com.MultiSelectionSpinner
    android:id="@+id/mySpinner1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

<Button
    android:id="@+id/getSelected"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Check"/>

<fragment 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:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapsAnzeigeActivity" />

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="?android:attr/windowBackground"
    app:menu="@menu/navigation" />

</LinearLayout>
Saikrishna Rajaraman
  • 3,205
  • 2
  • 16
  • 29
Tobias D
  • 87
  • 1
  • 2
  • 13

2 Answers2

1

Try with RelativeLayout

something like this

<RelativeLayout 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/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".fahrplanmap">

    <com.MultiSelectionSpinner
        android:id="@+id/mySpinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Button
        android:id="@+id/getSelected"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/mySpinner1"
        android:text="Check" />

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/navigation"
        android:layout_below="@+id/getSelected"
        tools:context=".MapsAnzeigeActivity" />

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="56dp"
        android:layout_alignParentBottom="true"
        android:background="?android:attr/windowBackground"
        app:menu="@menu/navigation" />
</RelativeLayout>

This is how it looks

Akshay Katariya
  • 1,464
  • 9
  • 20
1

you may try using framelayout to solve this issue try some thing like this

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <fragment 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:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapsAnzeigeActivity" />

<android.support.design.widget.BottomNavigationView
    android:id="@+id/navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="?android:attr/windowBackground"
    app:menu="@menu/navigation" />
</FrameLayout>
Hazem Ashraf
  • 310
  • 2
  • 8