Hi Everyone,
I am trying to set up my MapView to take up the full screen of the mobile device. I have tried wrapping a FrameLayout around the MapView, that didn't work. I tried setting the layout_weight of the MapView to 1, that didn't work. I tried using a MapFragment instead of the MapView, that didn't work. I have been stuck on this problem for days now and I am really not sure what I am doing wrong.
The app has one main activity - I have created several Fragments, which I will switch between, as the app gets used. Could the problem be with the way I have laid out my MainActivity (the activity where fragments will be swtiched onto)?
I have implemented the needed lifecycle methods for the MapView, on my fragment. Here is the XML Layout for the Fragment with the MapView:
This is the XML Layout for the MainActivity - where Fragments will be switched as the app is used:
This is the outcome I get each time for the map: http://imgur.com/uSAi3Vm
Please Help Me... Thanks.
I am trying to set up my MapView to take up the full screen of the mobile device. I have tried wrapping a FrameLayout around the MapView, that didn't work. I tried setting the layout_weight of the MapView to 1, that didn't work. I tried using a MapFragment instead of the MapView, that didn't work. I have been stuck on this problem for days now and I am really not sure what I am doing wrong.
The app has one main activity - I have created several Fragments, which I will switch between, as the app gets used. Could the problem be with the way I have laid out my MainActivity (the activity where fragments will be swtiched onto)?
I have implemented the needed lifecycle methods for the MapView, on my fragment. Here is the XML Layout for the Fragment with the MapView:
Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id = "@+id/mapRouteView"
android:orientation="vertical"
android:weightSum="1"
>
<com.google.android.gms.maps.MapView
android:layout_marginTop="10dp"
android:id = "@+id/mapRouteMapView"
android:layout_height="0dp"
android:layout_width="match_parent"
android:apiKey="@string/maps_api_key"
android:visibility="visible"
android:layout_weight="1"
>
</com.google.android.gms.maps.MapView>
</LinearLayout>
This is the XML Layout for the MainActivity - where Fragments will be switched as the app is used:
Code:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="allblacks.com.ibaleka_android_prototype.MainActivity"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id = "@+id/MainActivityToolbar"
android:background="@color/colorPrimary"
>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id = "@+id/MainActivityImageView"
android:layout_marginRight="5dp"
android:layout_marginLeft="1dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/ToolbarTextView"
android:id = "@+id/MainActivityTextView"
android:textAlignment="center"
/>
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id = "@+id/menuDrawerLayout"
>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id = "@+id/mainActivityScrollView"
android:fitsSystemWindows="true"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id = "@+id/MainActivityContentArea"
>
</FrameLayout>
</ScrollView>
<android.support.design.widget.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id = "@+id/mainActivityNavigationView"
android:layout_gravity="start"
android:textAlignment="center"
app:itemTextColor="@android:color/black"
></android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
This is the outcome I get each time for the map: http://imgur.com/uSAi3Vm
Please Help Me... Thanks.