2011-08-25 7 views
10

지도에서 사용자가 버튼을 미리 설정하여 mapView에 현재 위치로지도를 새로 고침하는 mapView에 일부 버튼을 배치해야하는 질문에서 알 수 있습니다. 나는 위의 버튼을 넣는 법을 알고 있지만,지도 위에 두는 법은 무엇입니까 ??? 누군가 샘플 코드를 가지고 있거나 도움이된다면 ...MapView에 버튼을 추가하려면 어떻게해야합니까?

답변

29

당신은 RelativeLayout을 사용하고 MapView 위에 버튼을 놓기를 원할 것입니다. Google 로고 위에 놓지 않도록하십시오. 다음은 샘플 XML이다 : 오버레이 항목에 대한

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <com.google.android.maps.MapView android:id="@+id/google_maps" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:apiKey="@string/maps_key"/> 
    <Button android:id="@+id/googlemaps_select_location" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      android:text="Select"/> 
</RelativeLayout> 
+0

감사합니다 남자 .. 이게 내가 찾고 있던 ... 감사합니다. DDD – Jovan

+0

고마워요! 이것은 나를 위해 도움이되었습니다! – pandre

관련 문제