마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

구글맵v2 이용시 맵위에 버튼을 추가할 수 있나요?

0 추천
구글맵v2 공부중인 학생입니다.

gMap = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

이런방식으로 구글맵을 가져와 사용중인데요

setMyLocationEnabled 등의  구글맵 기본 메소드를 통해서 생성되는 기본 버튼들 말고,

보통의 액티비티에서 사용하듯 제가 원하는 버튼을 구글맵 위에 추가하여 사용할수 있는 방법이 있나요?
멍청한놈 (220 포인트) 님이 2015년 10월 13일 질문

2개의 답변

0 추천
맵을 프레임레이아웃이나 릴레이티브레이아웃으로 감싸넣으면 됩니다.
커피한잔하고하자 (360 포인트) 님이 2015년 10월 13일 답변
0 추천

대충 이런 layout이면 됩니다. 아래는 close버튼을 갖고 있는 맵 예제

 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <fragment xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:scrollbars="vertical"
        class="com.google.android.gms.maps.SupportMapFragment"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/close"
        android:id="@+id/btn_close"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="10dp" />

</RelativeLayout>
cc1232 (35,280 포인트) 님이 2015년 10월 13일 답변
...