2013-03-12 2 views
4

화면 중앙에 고정되어있는 Google지도에 오버레이를 추가하여 사용자가 위치를 정교하게 선택할 수 있도록합니다.Google지도 v2에 십자 모양 오버레이 추가

현재 아래 코드는 가운데에 십자선 이미지가있는지도 뷰를 그렸지만 버튼이지도 뷰 아래에 있으므로지도 중심이 변경되고 십자선이 더 이상지도의 중심점을 나타내지 않으며 높이가 위로 이동했습니다 버튼의

I가 Android - Showing a crosshair in the center of my Google Map 살펴본하지만 단지 적합한 V1위한 :(I는 이미지 뷰와지도 단편 감싸 상대 배치를 사용하는 이러한 효과를 달성하기 위해

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/locationpicker_map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_above="@+id/locationpicker_add_venue" 
    android:clickable="true" 
    android:layout_weight="1" 
    class="com.google.android.gms.maps.SupportMapFragment"/> 
     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/crosshairs" 
      android:layout_gravity="center_vertical" 
      android:layout_centerInParent="true"/> 
     <Button 
     android:id="@+id/locationpicker_add_venue" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text = "Add new venue here" 
     android:layout_alignParentBottom="true"/> 
</RelativeLayout> 

답변

4

들어. 중심 보인다 아래의 예는 참조;

Crosshair centered on android google map

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/locationpicker_map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clickable="true" 
    android:layout_weight="1" 
    class="com.google.android.gms.maps.SupportMapFragment"/> 
     <ImageView 
      android:id="@+id/imageView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/crosshairs" 
      android:layout_gravity="center_vertical" 
      android:layout_centerInParent="true"/> 
     <Button 
     android:id="@+id/locationpicker_add_venue" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text = "Add new venue here" 
     style="@style/Buttonpurple_style" 
     android:layout_gravity="center" 
     android:layout_centerHorizontal="true" 
     android:layout_alignParentBottom="true" 
     /> 
</RelativeLayout>