【问题标题】:mapview goes to fill parent instead of wrap contentmapview 去填充父母而不是包装内容
【发布时间】:2011-10-04 09:59:21
【问题描述】:

我的应用程序中有一个地图视图。 我已经在相对布局中设置了 294x322 图像,并且在 relativelayout 下我添加了带有 wrap_conten 作为高度的 mapview,并且 wight 认为地图视图还将包含 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>

以下是我设计的图形布局

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

谁能告诉我如何摆脱这个问题?????

【问题讨论】:

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


    【解决方案1】:

    为了在 2 个布局之间垂直调整地图视图,我使用了“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"
    />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      • 2012-07-26
      • 1970-01-01
      • 2018-01-23
      • 2017-04-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多