2013-07-12 43 views
5

Tôi đang sử dụng một InfoWindowAdapter để thêm một infowindow tùy chỉnh để marker.Everything của tôi là tốt, ngoại trừ một điều, tôi không thể tìm thấy một cách để có một lợi thế cạnh tròn cho infowindow tôiThêm EGDE tròn đến một điểm đánh dấu bản đồ

tôi đang sử dụng đoạn mã google mapV2.Any về vấn đề này sẽ thực sự hữu ích

+0

làm u muốn hiển thị cửa sổ thông tin với góc tròn hoặc điểm u đặt dấu muốn hiển thị vòng? – TheFlash

+0

@Pratik tôi muốn hiển thị cửa sổ thông tin với góc tròn – Abx

+0

k chờ đợi tôi sẽ đăng câu trả lời. – TheFlash

Trả lời

12
gMap.setInfoWindowAdapter(new InfoWindowAdapter() { 

     @Override 
     public View getInfoWindow(Marker arg0) 
     { 
      View vMapInfo = ((Activity) context).getLayoutInflater().inflate(R.layout.map_info_layout, null); 
      return vMapInfo; 
     } 

     @Override 
     public View getInfoContents(Marker arg0) 
     { 
      //View v = getLayoutInflater().inflate(R.layout.map_info_layout, null); 
      return null;    

     } 
    }); 

map_info_layout.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:background="@drawable/bg_map_info" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:gravity="center_horizontal" 
> 

<RelativeLayout 
    android:layout_width="250dp" 
    android:layout_height="45dp" 
    android:background="@drawable/bg_map_info" 
    android:paddingTop="0dp" 
    android:paddingBottom="0dp" 
    android:paddingLeft="5dp" 
    android:paddingRight="5dp" 
    > 

    <TextView 
     android:id="@+id/tvMapStoreName" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="3dp" 
     android:layout_marginTop="2dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_toLeftOf="@+id/ivMapGo" 
     android:ellipsize="end" 
     android:lines="1" 
     android:text="test text test text test text test text " 
     android:textColor="#ffffff" 
     android:textSize="@dimen/txt_size_common" 
     android:textStyle="bold" /> 

    <ImageView 
     android:id="@+id/ivMapGo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:src="@drawable/ic_launcher" /> 

    <TextView 
     android:id="@+id/tvMapStoreDistance" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignLeft="@+id/tvMapStoreName" 
     android:layout_below="@+id/tvMapStoreName" 
     android:lines="1" 
     android:text="100 Miles" 
     android:textColor="#FFFFFF" 
     android:textSize="12dp" 
     android:textStyle="normal" /> 

</RelativeLayout> 



</LinearLayout> 

và dưới đây là XML của nền cửa sổ thông tin.

bg_map_info.xml

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
    <shape android:shape="rectangle"> 
     <gradient android:angle="-90" android:startColor="#a0333333" 
      android:endColor="#a0000000" /> 
     <corners 
      android:bottomLeftRadius="5dp" 
      android:bottomRightRadius="5dp" 
      android:topLeftRadius="5dp" 
      android:topRightRadius="5dp" />   

    </shape> 
</item> 
<item android:top="20dp"> 
    <shape android:shape="rectangle"> 
     <gradient android:angle="-90" android:startColor="#70000000" 
      android:endColor="#70000000" /> 
     <corners 
      android:bottomLeftRadius="5dp" 
      android:bottomRightRadius="5dp" 
      android:topLeftRadius="5dp" 
      android:topRightRadius="5dp" />  </shape> 
</item> 
</layer-list> 
+1

tôi đã thử mã của bạn nhưng wat nó làm là nó cho thấy một cái nhìn với các cạnh vuông và trong đó xem nó cung cấp cho một cái nhìn lưỡi tròn. – Abx

+0

@Abhilash thử câu trả lời đã chỉnh sửa của tôi.Tôi vừa thay đổi android: background = "# 00ffffff" thành android: background = "@ drawable/bg_map_info" – TheFlash

+0

điều này làm cho bố cục có góc tròn nhưng ẩn nội dung. bất kỳ ý tưởng tại sao điều này xảy ra? – TharakaNirmana

Các vấn đề liên quan