0

Im working on an activity that conatins a map and im trying to add buttons on top of it, here is how my xml looks like

xml mock-up

here is my xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/multi_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >

<FrameLayout
    android:id="@+id/container_a"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight="1" >
</FrameLayout>


<RelativeLayout
    android:layout_width="0dp"
     android:id="@+id/container_b"
    android:layout_height="match_parent"
    android:layout_weight="1" >

    <fragment
        android:id="@+id/map_fragment"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <RadioGroup
        android:id="@+id/radio_group_list_selector"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="#80000000"
        android:orientation="horizontal"
        android:padding="4dp" >

        <Button
            android:id="@+id/driving"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/bkg"
            android:drawableTop="@drawable/car"
            android:gravity="center_horizontal|center_vertical" />

        <Button
            android:id="@+id/radioAZ"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/bkg"
            android:drawableTop="@drawable/walk"
            android:gravity="center_horizontal|center_vertical" />

        <Button
            android:id="@+id/bicycling"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:background="@drawable/bkg"
            android:drawableTop="@drawable/bicycle"
            android:gravity="center_horizontal|center_vertical" />
    </RadioGroup>
</RelativeLayout>

However when i run the app, that map still goes on top of the buttons, anyone know how i can get the buttons on top of the map so that the user can see and use them? something along the line of z-index or so?

Ziv Kesten
  • 1,206
  • 25
  • 41

1 Answers1

1

You are placing a SupportMapFragment on XML and also replacing the FrameLayout that contains that fragment and the buttons with another fragment.

Jorge Martín
  • 268
  • 3
  • 13
  • so i need to add the button progrematicaly after i add the map? – Ziv Kesten Mar 26 '14 at 16:23
  • I don't understand why you are adding the Map again on code. You already have it on the XML file. If you want to get it and use it in code you should use `getSupportFragmentManager().findFragmentById(R.id.fragment2);`. – Jorge Martín Mar 26 '14 at 16:32
  • yes i saw that error its was left from a previous version im sorry about that, however i still cant seem to see the buttons, the map is covering them, any idea? – Ziv Kesten Mar 26 '14 at 16:38
  • The buttons should be visible as they are the last items on the RelativeLayout and have the highest z-index. I have a similar layout in one of my apps and I'm doing it almost the same way as you - I just don't use the RadioGroup item. I really don't know why they aren't showing... – Jorge Martín Mar 26 '14 at 16:48
  • that is where i started, however, the map still covers the buttons, i see them for a fraction of a second when the map changes – Ziv Kesten Mar 26 '14 at 17:00
  • Are you sure that you are not replacing anything on code now? – Jorge Martín Mar 26 '14 at 17:02
  • i double checked, it looks like the map is added but i am not adding it anywhere – Ziv Kesten Mar 26 '14 at 17:26
  • i found it! the code is long but there was an onResumeFragment function that did it, it works now! thank you! – Ziv Kesten Mar 26 '14 at 18:42