2011-04-28 11 views
0

두 개의 버튼과 MapView가 포함 된 레이아웃을 만들고 있습니다. 버튼은 MapView의 위와 아래에 있어야합니다. Layout (Relative, Linear, Frame ...)의 여러 조합을 시도했지만 layout_height = "200dp"와 같은 특정 높이를 사용하지 않으면 MapView가 layout_height = wrap_content를 지원하지 않습니다.MapView가 지원하지 않습니다. layout_height = wrap_content

상단 버튼이 표시되지만 하단 버튼은 표시되지 않습니다. 아래는 나의 테스트 XML 파일이다.

제안 사항?

안드로이드 : layout_width = "fill_parent" 안드로이드 : layout_height = "fill_parent" >

<Button  
    android:id="@+id/btn1" 
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content" 
    android:text="Button1" 
    android:background="#FF0000" /> 

<com.google.android.maps.MapView 
    android:id="@+id/map1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:apiKey="my map key (removed for example)" 
/>   

<Button  
    android:id="@+id/btn2" 
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content" 
    android:text="Button2" 
    android:background="#00FF00" />  

답변

0

나는 새로운 기계에있어 및 테스트하기 위해 아무것도하지 않는 이것과 함께,하지만이 작동 할 수 있습니다 :

<RelativeLayout 
android:layout_width="fill_parent"   
android:layout_height="fill_parent"> 
<Button  
    android:id="@+id/btn1" 
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content" 
    android:text="Button1" 
    android:background="#FF0000" /> 

<Button  
    android:id="@+id/btn2" 
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content" 
    android:text="Button2" 
    android:background="#00FF00" />  

<com.google.android.maps.MapView 
    android:id="@+id/map1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:apiKey="my map key (removed for example)" 
    android:layout_below="@id/btn1" 
    android:layout_above="@id/btn2" 
/></RelativeLayout> 
+0

감사합니다. Mapview는 여전히 다른 레이아웃에서는 제대로 작동하지 않지만 이렇게해도됩니다. – RickR

1

내 문제는 내 mapview 베팅했다 단추 대신 두 개의 레이아웃을 사용), "height = 0dp"및 "weight = 1"으로 해결하여 맵뷰가 위와 아래 레이아웃에 맞게 조정됩니다.

<com.google.android.maps.MapView 
    android:id="@+id/map1" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:apiKey="my map key (removed for example)" 
/> 
관련 문제