2013-11-07 3 views
0

Я использую карты Google v2 для рисования карт. Мне нужно отобразить окно поиска поверх карт, которые привязаны к вершине экрана. Я пробовал много способов наложить его, но он не работает. Существует ли API для наложения пользовательских представлений на карты?Как добавить значок поиска через карты Google?

ответ

1

Вы можете использовать RelativeLayout, например так:

<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> 

В коде, используйте BringToFront() метод.

// show editext over map 
mEditText.bringToFront(); 
Смежные вопросы