MapView not supporting layout
I'm building a layout that contains two buttons and a MapView. The buttons should be placed above and below the MapView. I've tried several combinations of layouts (Relative, Linear, Frame...), but the MapView does not support the layout_height=wrap_content unless I use a specific height like layout_height="200dp".
The tope button is displayed, but the bottom button is not. Below is my test XML file.
Any suggestions?
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" />
我有同样的问题(我的地图视图是在两个布局之间,而不是按钮),并解决它与“高度= 0dp”和“重量= 1”,所以mapview调整为上述和下面的布局。
<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)"
/>
我在一台全新的机器上,没有任何东西可以测试,但这可能会起作用:
<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>
链接地址: http://www.djcxy.com/p/16648.html
上一篇: 如何在Android中播放音频文件?
下一篇: MapView不支持布局