mapview用于填充父级而不是包装内容

时间:2011-10-04 09:59:22

标签: android android-layout android-widget android-manifest

我的应用程序中有一个mapview。 我在相对布局中设置了294x322 imgage并且在relativelayout下我添加了mapview和wrap_conten作为高度并且认为地图视图还将包含heleht的大小和relativelayout的294x322的重量。但是在运行时我的mapview将填充parent.one解决方案我发现给背景图像的相对布局给出了静态高度宽度,但问题是我有两个同名的图像,我在hdpi和mdpi文件夹中进行了操作。所以它不能用于多屏幕重建。

这里我添加了我的xml文件

 <!-- MapView -->

            <RelativeLayout 

                    android:id="@+id/layout_mapRestaurant"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/rlBtnView" 
                    android:layout_centerHorizontal="true"
                    android:paddingLeft="15dip"
                    android:paddingTop="15dip"
                    android:paddingRight="15dip"
                    android:paddingBottom="40dip" 
                    android:layout_marginTop="-25dip"
                    android:background="@drawable/mapbg"

                    >
                              <com.google.android.maps.MapView

                   xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/mapview_SearchResult"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:clickable="true" 
                    android:background="@drawable/bg_border" 

                 />

     </RelativeLayout>

以下是我设计的图形布局

enter image description here

以下是我在运行时显示的实际布局。 enter image description here

谁能告诉我如何从这个问题中解脱出来?????

1 个答案:

答案 0 :(得分:0)

要在2个布局之间垂直调整mapview,我使用“height = 0dp”和“weight = 1”,对我来说效果很好:

<com.google.android.maps.MapView
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:clickable="true"
    android:apiKey="xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
/>
相关问题