2011-08-23 3 views
1

Google 맵에 Map View balloon을 구현하려고하지만 풍선의 레이아웃으로 차단합니다.
풍선의 크기는 콘텐츠 크기 여야하지만 크기가 커서 배경 drawable 크기가 필요합니다. 누군가 다른 사람이 제공 한 꽤 큰 풍선 9-patch image을 가지고 있기 때문에 작은 풍선 내용이 모든 화면 (드로어 블 크기)을 차지합니다. 배경 drawable 대신 내용보기를 래핑하는 방법은 무엇입니까?

나는이 관련 질문을했다 : How to wrap content views rather than background drawable?, 정확히 내가 원하는,하지만합니다 ( ImageView SRC가 wrap_content 또는 fill_parent로, 너무 드로어 블 크기를 가지고 있기 때문에하는 FrameLayout 같은 문제를 만들어 사용)는 더 정확한 답이 없다 . (빨간색 공간이 삭제 될 수 있습니다) 여기
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="wrap_content" android:id="@+id/balloon_main_layout" 
    android:orientation="horizontal" android:clickable="true" 
    android:focusable="true" android:focusableInTouchMode="true" 
    android:layout_width="wrap_content" android:background="@drawable/info_bulle_selector"> 
    <LinearLayout android:id="@+id/linearLayout1" 
     android:layout_height="wrap_content" android:layout_width="0dp" 
     android:layout_weight="1"> 
     <TextView android:layout_height="wrap_content" 
      android:layout_width="wrap_content" android:text="TextView" 
      android:id="@+id/balloon_item_title" android:textColor="#ffffff"></TextView> 
    </LinearLayout> 
    <ImageView android:id="@+id/balloon_close" 
     android:layout_marginLeft="5dp" android:src="@drawable/fermer_selector" 
     android:scaleType="fitXY" android:layout_height="30dp" 
     android:layout_width="30dp"></ImageView> 
</LinearLayout> 

내가 무슨의 화면입니다 : 여기

내 레이아웃입니다
Current baloon layout

이 문제를 해결하기 위해 어떤 생각이있는 경우 (배경 이미지로 내 레이아웃을 디자인 할 때 종종 가지고있는), 그것은 좋을 것입니다.
미리 감사드립니다.

편집 : 여기
아홉 패치 PNG : 특히,

1) 풍선 9 패치 이미지를 축소합니다 nine-patch balloon

답변

2

나는 당신의 문제를 이해 할 때 바로, 당신은 두 가지 옵션이 있습니다 9- 패치 이미지의 비 신축성 및 패딩 영역이므로 작은 컨텐츠에 더 잘 맞을 수 있습니다. 여기에 더 문서를 참조하십시오 : http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

편집 :

나는 점 1에서 발견으로

), 당신의 9 패치 이미지가 너무 컸다. 폭은 330px이고 높이는 74px입니다. 귀하의 콘텐츠가 전체 배경 이미지 너비와 높이를 채우지 않기 때문에 레이아웃 내에 공백이 생깁니다.

가능한 해결 방법으로 9 패치 이미지를 축소하십시오. 나는 150 픽셀의 폭과 34px의 높이로 이미지를 수축하고 나는 다음과 같은 결과를 얻었다 : 여기

screen shows 3 balloons with different contents

수축 9 패치 이미지 : enter image description here

+0

예, 내가 너무 생각을 첫 번째 해결 방법이지만 일종의 트릭이기 때문에 일반적인 문제는 해결되지 않으므로 다른 해결책이 있는지 궁금합니다. 두 번째 해결 방법은 작은 삼각형 때문에 풍선에 적합하지 않습니다. 그러나 해결책을 수락하기 전에 다른 대답이있을 때까지 기다릴 것입니다. – Astrorvald

+0

9 패치 이미지를 업로드 할 수 있습니까? – AZ13

+0

나는 일하는 해결책으로 나의 대답을 편집했다. – AZ13

관련 문제