Reputation: 1451
I am using Google maps v2 to draw maps. I need to display a search box on top of the maps which is anchored to top of the screen. I tried many ways to overlay it but it is not working. Is there an API to overlay custom views on maps?
Upvotes: 0
Views: 661
Reputation: 967
You can use RelativeLayout, for example like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/editTextLocation"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="60dp"
android:layout_marginRight="60dp"
android:layout_marginTop="13dp"
android:background="@android:color/white"
android:hint="@string/search"
android:imeOptions="actionSearch"
android:inputType="text"
android:padding="5dp" />
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/buttonMap"
android:layout_alignParentTop="true" />
<Button
android:id="@+id/buttonMap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
>
</Button>
In code, use bringToFront() method.
// show editext over map
mEditText.bringToFront();
Upvotes: 1