Siva K
Siva K

Reputation: 4968

how to show a button in the mapView of an android

in my app i am using the view flipper. One side of the flip i have placed some text and edit text view. In the other part of the flip i have the map view.

To flip between these two views i am using the swipe concept. I am able to swipe from the text view to the map view. But to get back to the text page from view i decided to place a button in the in the map view but still, the button is not visible.

Following is my layout of the view flipper

<ViewFlipper android:background="#000000"  android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/viewFlipper1">
           <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"
                         android:layout_height="wrap_content" android:layout_marginTop="25dip"
                         android:layout_marginBottom="10dip">
                  <TextView android:id="@+id/distance" android:text="0.0" android:textColor="#ffffff"
                            android:layout_width="80dip" android:layout_height="wrap_content"
                            android:gravity="center_vertical|right" android:layout_marginLeft="18dip"
                            android:textSize="20dip">
                  </TextView>     

                  <Spinner android:id="@+id/unitspinner" android:layout_width="fill_parent"
                           android:layout_height="wrap_content" android:drawSelectorOnTop="true"
                           android:prompt="@string/unit_prompt"/>           
            </LinearLayout>

            <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
<com.google.android.maps.MapView android:id="@+id/mapView"
                                 android:layout_width="wrap_content"
                                 android:layout_height="match_parent"
                                 android:enabled="true"
                                 android:clickable="true"                                 android:apiKey="0XXXXXXXXXXXXXXXXXXXX">
 <Button android:id="@+id/widget306" android:layout_width="wrap_content" android:layout_height="wrap_content"
                   android:text="Back">
           </Button>
               </com.google.android.maps.MapView>

                  <LinearLayout android:id="@+id/zoom" android:layout_width="wrap_content" android:layout_height="wrap_content" 
                                android:layout_alignParentBottom="true" android:layout_centerHorizontal="true"> 
                  </LinearLayout> 

            </LinearLayout>
        </ViewFlipper>

how to get the button to be visible. Please help me....

Upvotes: 0

Views: 2898

Answers (1)

Siva K
Siva K

Reputation: 4968

The buttons are visible only in the relative layout. the xml file must be as follows

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


<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="0y6Hyjz6Kxo-NOV_9KHYF7-ECYeGt99xeyVU3IQ"/>

<Button 
    android:id="@+id/select_3" 
    android:layout_marginTop="13dp"
    android:layout_height = "wrap_content"
    android:layout_width  = "wrap_content"
    android:onClick="selfSelectCenterLocation">
</Button>
</RelativeLayout>

Upvotes: 1

Related Questions