0

I am trying to make the mapfragment work such that the map shows beneath the button and the text view.

With the layout below, the map works but the button and the text view take up space at the bottom of the screen.

I have tried various options like changing the layout to relative out etc, but when I use relative layout, the map does not display at all.

Is there a way to achieve what I want?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <fragment
        android:id="@+id/map"
        android:layout_width="wrap_content"
        android:layout_height="0dp"
        android:layout_weight="1"
        class="com.google.android.gms.maps.MapFragment" />

    <AutoCompleteTextView
        android:id="@+id/stationName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="24dp"
        android:layout_marginLeft="4dp"
        android:layout_marginRight="4dp"
        android:layout_marginTop="16dp"
        android:fontFamily="sans-serif-condensed"
        android:hint="Select/Type station name to track"
        android:text="" />

    <Button
        android:id="@+id/but1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/stationName"
        android:background="@drawable/black_button"
        android:fontFamily="sans-serif-condensed"
        android:text="Start Tracking"
        android:textColor="@color/white"
        android:textSize="20dp" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:paddingTop="15dp"
        android:textAlignment="center"
        android:textSize="14dp" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:paddingTop="15dp"
        android:textAlignment="center"
        android:textSize="14dp" />

</LinearLayout>
user2260040
  • 1,275
  • 1
  • 13
  • 26

1 Answers1

1

I am trying to make the mapfragment work such that the map shows beneath the button and the text view.

You need a FrameLayout. The child views are drawn in a stack, with the most recently added child on top. This will suffice your need.

An SO User
  • 24,612
  • 35
  • 133
  • 221
  • Changed LinearLayout to FrameLayout and now the only thing that shows is the Button. Nothing else :( – user2260040 Oct 02 '14 at 07:40
  • @user2260040 See the tutorial. It will answer your question. – An SO User Oct 02 '14 at 07:42
  • Maybe Duplicate question put your buttons and such in a relative layout. http://stackoverflow.com/questions/24130000/add-custom-button-to-mapfragment-with-the-same-style-of-maps-app/24131755#24131755 – danny117 Oct 02 '14 at 09:24