MapView не поддерживает layout_height = wrap_content - PullRequest
0 голосов
/ 28 апреля 2011

Я строю макет, который содержит две кнопки и MapView.Кнопки должны быть расположены выше и ниже MapView.Я пробовал несколько комбинаций макетов (Относительный, Линейный, Рамочный ...), но MapView не поддерживает layout_height = wrap_content, если я не использую определенную высоту, такую ​​как layout_height = "200dp".

Топкнопка отображается, а нижняя кнопка - нет.Ниже мой тестовый XML-файл.

Есть предложения?

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" />

<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" />      

Ответы [ 2 ]

1 голос
/ 01 июня 2012

У меня была та же проблема (мой вид карты был между двумя раскладками вместо кнопок), и я решил ее с помощью «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)"
/> 
0 голосов
/ 28 апреля 2011

Я на совершенно новой машине, и мне не с чем протестировать, но это может сработать:

<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>
...