I have tried like 5 different ways to try and get buttons to show over a maps activity, but no matter what I try I can't seem to get them to show up, anybody know what I am doing wrong? This pertains to android studio
Here is code from activity_maps.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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/currentloca"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:backgroundTint="#818181"
android:orientation="vertical"
android:visibility="visible">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="553dp"
tools:context=".MapsActivity" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<Button
android:id="#+id/zoomin"
android:layout_width="205dp"
android:layout_height="wrap_content"
android:onClick="onZoom"
android:text="Zoom In" />
<Button
android:id="#+id/zoomout"
android:layout_width="205dp"
android:layout_height="wrap_content"
android:onClick="onZoom"
android:text="Zoom Out" />
</androidx.appcompat.widget.LinearLayoutCompat>
</FrameLayout>
As suggested in comment, I think your need is a relative layout. Here is a example.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="553dp"
tools:context=".MapsActivity" />
<LinearLayout
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button />
<Button />
</LinearLayout>
</RelativeLayout>
This way the buttons will appears in the top of the map fragment.
You should use FrameLayout or its sort instead of LinearLayout. Below is just showing a structure for an explanation:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button />
<Button />
</LinearLayout>
</FrameLayout>
LinearLayout lays its child views on a horizontal or vertical line. While FrameLayout over-lays its children.
About your actual code, at first, replace (overwrite) the surrounding (outer most) LinearLayout:
<LinearLayout
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/currentloca"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="#818181"
android:orientation="vertical"
android:visibility="visible">
(...)
</LinearLayout>
with FrameLayout:
<FrameLayout
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/currentloca"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="#818181"
android:orientation="vertical"
android:visibility="visible">
(...)
</FrameLayout>
Remove the first parent LinearLayout from your code.
Updated code should look like this.
<RelativeLayout 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/currentloca"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="#818181"
android:orientation="vertical"
android:visibility="visible">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="555dp">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="553dp"
tools:context=".MapsActivity" />
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal">
<Button
android:id="#+id/zoomin"
android:layout_width="205dp"
android:layout_height="wrap_content"
android:onClick="onZoom"
android:text="Zoom In" />
<Button
android:id="#+id/zoomout"
android:layout_width="205dp"
android:layout_height="wrap_content"
android:onClick="onZoom"
android:text="Zoom Out" />
</androidx.appcompat.widget.LinearLayoutCompat>
</FrameLayout>
</RelativeLayout>
If you want your Views to potentially overlap, use a FrameLayout. If you want them displayed linearly, use a LinearLayout
Well, you should use ConstriantLayout and LinearLayout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="vertical"
tools:context=".Activities.Maps">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
map:layout_constraintEnd_toEndOf="parent"
map:layout_constraintStart_toStartOf="parent"
map:layout_constraintTop_toTopOf="parent">
<Button
android:id="#+id/zoomin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:onClick="onZoom"
android:text="Zoom In" />
<Button
android:id="#+id/zoomout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:layout_weight="1"
android:onClick="onZoom"
android:text="Zoom Out" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Related
I am trying to show three elements search box, google map and one button in vertical order. The problem is only search box and map show and below this no button is displayed. I have set orientation as vertical. Below is my code, please suggest any solution.
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="mypackage">
<fragment
android:id="#+id/place_autocomplete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
/>
<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="wrap_content"
android:layout_height="wrap_content"
tools:context="mypackage" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
Try this make ScrollView as your root layout like below code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:fillViewport="true">
<LinearLayout
tools:context="mypackage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="#+id/place_autocomplete"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
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="wrap_content"
android:layout_height="wrap_content"
tools:context="mypackage" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</ScrollView>
Or Provide weight to your fragments as per your requirement like this
<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"
android:orientation="vertical"
tools:context="mypackage">
<fragment
android:id="#+id/place_autocomplete"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="wrap_content"
android:layout_weight="1"
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:layout_weight="1"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context="mypackage" />
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
SupportMapFragment is suggested to be set with android:layout_height="match_parent", so a linear layout with another view below the map won't work. You can achieve that by using a relative layout:
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="mypackage">
<fragment
android:id="#+id/place_autocomplete"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"/>
<Button
android:id="#+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Button" />
<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"
android:layout_below="#id/place_autocomplete"
android:layout_above="#id/button2"
tools:context="mypackage" />
</RelativeLayout>
I tried adding the floating action button but just not able to get it to position in the expected place.I've the xml along with the obtained and expected image.
Actually I want two such floating action buttons one on top of the other.
MapsActivity
<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/maplinear"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:theme="#style/AppTheme">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="#+id/place_autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<fragment 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="com.example.srinivas.democomplete.MapsActivity" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:clickable="true"
app:srcCompat="#android:drawable/ic_dialog_email"
/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="#+id/autoComplete"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#303F9F"
android:text="Auto Complete"
android:textColor="#ffffff"
android:visibility="visible" />
<View
android:layout_width="0.5dp"
android:layout_height="match_parent"
android:background="#ffffff" />
<Button
android:id="#+id/bsolarpanel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#303F9F"
android:text="Add solar panels"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
Any help would be great thx!
Just remove the line
android:layout_gravity="bottom|end"
You can use margin to set it according to your need
UPDATE
You can add some more attributes like
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
I would like to make my activity like Google Maps.
I have added a bottom sheet but, when I run the application the bottom sheet appeared below the maps while other activities appear above it without any problem.
How to make it appear above the map like this?
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_marginBottom="56dp"/>
</RelativeLayout>
<!-- Bottom Sheet Content -->
<include layout="#layout/content_bottom_sheet" android:fitsSystemWindows="true"/>
</android.support.design.widget.CoordinatorLayout>
Use below code
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="bottom|center_horizontal"
android:orientation="horizontal"
android:layout_gravity="bottom">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/texi_white"
android:gravity="center"
android:text="Map"
android:textAllCaps="false"
android:textColor="#android:color/darker_gray"
android:textStyle="bold" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/food_white"
android:gravity="center"
android:text="List"
android:textAllCaps="false"
android:textColor="#android:color/darker_gray"
android:textStyle="bold" />
</LinearLayout>
</FrameLayout>
`
I want to Place floating action button on top of map fragment.
My map fragment is completely filled the entire screen. When I place a floating action button it is not coming on top of map fragment
Please refer the image attached:
Please find layout code here
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_small"
>
<fragment
android:id="#+id/autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<!--<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/bell32"
android:visibility="invisible"
/>
<android.support.v7.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/alarm_on_switch"
android:layout_gravity="right|top"
android:layout_marginRight="#dimen/margin_small"
android:drawableLeft="#drawable/bell32"
/>-->
</android.support.v7.widget.CardView>
<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"
tools:context="reminder.locrem.com.locationreminder.MapsActivity"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_margin="16dp"
android:src="#drawable/done"
app:layout_anchorGravity="bottom|right|end"
app:elevation="4dp" />
</LinearLayout>
</ScrollView>
You can use FrameLayout to acieve what you want.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_small">
<fragment
android:id="#+id/autocomplete_fragment"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="reminder.locrem.com.locationreminder.MapsActivity" />
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_margin="16dp"
android:src="#drawable/done"
app:elevation="4dp"
app:layout_anchorGravity="bottom|right|end" />
</FrameLayout>
</LinearLayout>
</ScrollView>
Hi you can try to this code..
<RelativeLayout 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"
tools:context=".MainActivity">
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="30dp"
android:background="#android:color/transparent"
android:clickable="true"
android:onClick="myLocationCall"
android:rotation="0" />
</RelativeLayout>
I had a similar requirement, I used android material floating action button.
The button came with material design.
The trick was to add the button inside the fragment and then change the margin gravity accordingly.
<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="0dp"
android:layout_weight="1"
tools:context=".ui.Maps.MapsActivity" >
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/floatingActionButton2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_gravity="end|bottom"
android:layout_margin="8dp"
android:src="#android:drawable/ic_menu_revert" />
</fragment>
You just need to change the android:layout_gravity="top|right"
<android.support.design.widget.CoordinatorLayout
android:id="#+id/main_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.maps.MapView
android:id="#+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_margin="16dp"
android:src="#drawable/ic_done"
app:layout_anchor="#id/lvToDoList"
app:layout_anchorGravity="bottom|right|end" />
</android.support.design.widget.CoordinatorLayout>
Currently I'm trying to have a layout that looks like this:
[text field]
[map fragment]
[ad]
However, the map covers any component that comes below it. I'm using essentially the same exact layout as I am in another activity where it is component -> fragment -> ad and that displays perfectly fine. Below is my xml. Thanks for the help!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="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:orientation="vertical">
<EditText
android:id="#+id/query_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search for tweets here..." />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MapsActivity"
tools:layout="#layout/test"
map:uiZoomControls="false"
/>
<ProgressBar
android:id="#+id/map_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/list_ad_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/ad_unit"
/>
Edit: Adding android:layout_weight="1" to the RelativeLayout got it to display correctly. If anyone can explain why or give a better solution that would be awesome. Here's the editted code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="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:orientation="vertical">
<EditText
android:id="#+id/query_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search for tweets here..." />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MapsActivity"
tools:layout="#layout/test"
/>
<ProgressBar
android:id="#+id/map_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
<com.google.android.gms.ads.AdView
android:id="#+id/list_ad_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-XXXXXX"
/>
Can you try changing to RelativeLayout and using the layout_above in your xml. That should solve this issue.
Refer following code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="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:orientation="vertical" >
<EditText
android:id="#+id/query_field"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Search for tweets here..." />
<com.google.android.gms.ads.AdView
android:id="#+id/list_ad_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/ad_unit" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_above="#+id/list_ad_map">
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
map:uiZoomControls="false"
tools:context=".MapsActivity"
tools:layout="#layout/test" />
<ProgressBar
android:id="#+id/map_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:indeterminate="true"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>