I've got Activity with MapFragment and simple LenearLayout with buttons. On the image you can see little padding (about 3 dp and gray colored) between LienarLaouyt and Map. This padding belongs to mapFragment - i checked it by switching background color of main layout and linear layout. How can i remove it?
Here is the xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/select_period_button_label"
android:id="#+id/fragmentHistory_selectPeriodButton"
android:textSize="20sp"
android:layout_weight="1"
android:background="#drawable/control_button_selector"
android:textAllCaps="false" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/track_button_label"
android:id="#+id/fragmentHistory_trackButton"
android:textSize="20sp"
android:layout_weight="1"
android:background="#drawable/control_button_selector"
android:textAllCaps="false" />
</LinearLayout>
<fragment
android:id="#+id/activityDeviceCurrentLocation_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Try This...
<fragment
android:id="#+id/activityDeviceCurrentLocation_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp" />
Related
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>
doing this layer work and can't figure out how to put layers below ones I made when the android orientation is horizontal, it keeps pushing my layer to the outsidie I have a pics what I have done and how it has to look, if you have any ideas would be nice to hear, thank you in advance.How it has to look
and What I have done
<?xml version="1.0" encoding="utf-8"?>
<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=".MainActivity2">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<TextView
android:layout_width="140dp"
android:layout_height="300dp"
android:background="#FA0000" />
<TextView
android:layout_width="140dp"
android:layout_height="300dp"
android:background="#03ED0F" />
<TextView
android:id="#+id/blue"
android:layout_width="140dp"
android:layout_height="300dp"
android:background="#0027C3"
/>
<TextView
android:layout_below="#id/blue"
android:layout_width="100dp"
android:layout_height="10dp"
android:background="#000000" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
If you are using
you should use these attribute to control the position
app:layout_constraintTop_toBottomOf
app:layout_constraintTop_toTopOf
app:layout_constraintTop_toStartOf
app:layout_constraintTop_toRightOf
based on what it should look like, you can try
<?xml version="1.0" encoding="utf-8"?>
<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">
<LinearLayout
android:id="#+id/ll_horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="140dp"
android:layout_height="300dp"
android:background="#FA0000" />
<TextView
android:layout_width="140dp"
android:layout_height="300dp"
android:background="#03ED0F" />
<TextView
android:layout_width="140dp"
android:layout_height="300dp"
android:background="#0027C3"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/ll_horizontal"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#FA0000" />
<TextView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#03ED0F" />
<TextView
android:id="#+id/blue"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#0027C3"
/>
</LinearLayout>
it should look like this
Use 2 seperate LinearLayout one below other in root.
One for horigontal views. Second for vertical views.
And use weight_sum property in LinearLayout, along with weight property in child views to distribute child views eqally.
I am trying to create a layout with an embedded google map fragment and some information about selected markers below the map. I want the information below the map to only take up the space that it needs and give the rest of the space to the map.
As far as I understand it, layout_weight assigns extra space to the different widgets proportional to value given. So if I have a widget with layout_weight = 1, and another widget with layout_weight = 0 the first widget will take up all the extra space, and the second will only take what it needs. So if I give the second widget layout_height = wrap_content, then I should get what I want. However, this doesn't seem to be the case in practice. I have changed a lot of the values, and either one of the widgets take up all the space, or neither take up any. The only way I have been able to get them to show up normally is by setting the layout_height of the second widget to a specific value.
This may be part of the issue, but I am populating the widgets map_frag_event_icon, map_frag_person, and map_frag_event_details dynamically.
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="#dimen/fragment_margins"
android:orientation="vertical">
<fragment
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map_frag_google_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingBottom="#dimen/fragment_margins"
tools:context=".fragment.MapFragment"/>
<LinearLayout
android:id="#+id/map_frag_event_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="#+id/map_frag_event_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/icon_padding"
android:layout_weight="0" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical">
<TextView
android:id="#+id/map_frag_event_person"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size"/>
<TextView
android:id="#+id/map_frag_event_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
strings.xml
<resources>
<string name="app_name">Family Map</string>
<string name="title_activity_maps">Map</string>
<dimen name="fragment_margins">8dp</dimen>
<dimen name="horizontal_layout_padding">8dp</dimen>
<dimen name="vertical_layout_padding">4dp</dimen>
<dimen name="icon_size">48sp</dimen>
<dimen name="icon_padding">8dp</dimen>
<dimen name="text_size">20sp</dimen>
<dimen name="small_text_size">14sp</dimen>
<dimen name="large_text_size">24sp</dimen>
<dimen name="map_event_layout_height">120sp</dimen>
<dimen name="map_event_icon_size">40sp</dimen>
</resources>
EDIT
Here is the general design I am looking for, but I want the white space with the text to be as small as possible, and I want to create a setting to change the text size, so the the bottom white space should be dynamic.
Please give an explanation of what is going on along with a solution if you can.
In the fragment keep the android:layout_weight="1" but in the LinearLayout apply, for example, android:layout_weight="0.5". Check the outcome and then change the values according to your needs. Look at it a bit as relational percentages, so 1 to 0.5 would be 66% to 33%
Try with below layout :
<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map_frag_google_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/map_frag_event_layout"
android:paddingBottom="#dimen/fragment_margins"
tools:context=".fragment.MapFragment" />
<LinearLayout
android:id="#+id/map_frag_event_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="#+id/map_frag_event_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:padding="#dimen/icon_padding" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/map_frag_event_person"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size" />
<TextView
android:id="#+id/map_frag_event_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try below code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/fragment_margins"
android:orientation="vertical">
<fragment
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map_frag_google_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="#+id/map_frag_google_map"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingBottom="#dimen/fragment_margins"
tools:context=".fragment.MapFragment" />
<LinearLayout
android:id="#+id/map_frag_event_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="#+id/map_frag_event_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/icon_padding"
android:src="#mipmap/ic_launcher" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/map_frag_event_person"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size" />
<TextView
android:id="#+id/map_frag_event_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Replace your xml code with this,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_margin="#dimen/fragment_margins"
android:orientation="vertical">
<fragment
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map_frag_google_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.8"
android:paddingBottom="#dimen/fragment_margins"
tools:context=".fragment.MapFragment"/>
<LinearLayout
android:id="#+id/map_frag_event_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="#+id/map_frag_event_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/icon_padding"
android:layout_weight="0" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical">
<TextView
android:id="#+id/map_frag_event_person"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size"/>
<TextView
android:id="#+id/map_frag_event_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size"/>
</LinearLayout>
</LinearLayout>
Your are setting weight to 1 for both the views. So
I found two issues with my original code that I posted. I don't know when I added that during my original testing, but there were two fatal errors. In the root LinearLayout I had layout_height = "0dp" and it should have been layout_height = "match_parent". And in the LinearLayout that contained the two TextViews, I had layout_height = "match_parent" and it should have been layout_height = "wrap_content".
With those two errors fixed, #MuhammadMuzammilSharif's original comment about removing layout_weight = "0" worked.
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/fragment_margins"
android:orientation="vertical">
<fragment
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map_frag_google_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:paddingBottom="#dimen/fragment_margins"
tools:context=".fragment.MapFragment"/>
<LinearLayout
android:id="#+id/map_frag_event_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="#+id/map_frag_event_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/icon_padding"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical">
<TextView
android:id="#+id/map_frag_event_person"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size"/>
<TextView
android:id="#+id/map_frag_event_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="#dimen/text_size"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
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 add two aligned buttons below google map.I have tried adding buttons below but its not showing and whenever i try to change size of map,interface gets different for different devices. how can i do it? Please help. Here is my code given below without button code -
activity_maps.xml -
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/etSearch"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="search"
android:id="#+id/btnSearch"
android:layout_gravity="end"
style="?android:attr/buttonStyleSmall"
android:onClick="onSearch" />
</LinearLayout>
<fragment 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:id="#+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
</LinearLayout>
If I guessed right your problem is that any Buttons below the map fragment (inside the main LinearLayout) are not visible. This can be solved by setting the map fragment's layout_height to 0dp and giving it a layout_weight of 1. The UI elements above and below the map fragment should have the layout_height set to wrap_content just like you have done.
The idea is that the other UI elements use just the amount of the screen height that they need and the map fragment will then use all the remaining space. A similar approach can commonly be used in all kinds of layouts that have some elements with fixed height/width and one element that is supposed to scale to an optimal height/width.
As XML:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/etSearch"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="search"
android:id="#+id/btnSearch"
android:layout_gravity="end"
style="?android:attr/buttonStyleSmall"
android:onClick="onSearch" />
</LinearLayout>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
<!--The Buttons below the map fragment-->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/button2" />
</LinearLayout>
</LinearLayout>
You can do it by specifying layout_weight attribute for map fragment and linear layout that holds editText and a button.
For example:
<LinearLayout
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content">
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="#+id/etSearch"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="search"
android:id="#+id/btnSearch"
android:layout_gravity="end"
style="?android:attr/buttonStyleSmall"
android:onClick="onSearch" />
</LinearLayout>
<fragment 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:id="#+id/map"
android:layout_weight="1"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
This will split the space equally for map fragment and linear layout, but feel free to try different numbers to achieve what you want