开发者

mapview goes to fill parent instead of wrap content

i 开发者_运维知识库have an mapview in my application. i had set 294x322 imgage in relative layout and under relativelayout i have added mapview with wrap_conten as height and wight thought that map view will also contain the size of heiht and weight 294x322 of relativelayout.but at runtime my mapview goes to fill parent.one solution i had found is give static height width to relative layout as of background image but the problem is i have two images with same name which i had puted in hdpi and mdpi folder.so it would not work for multiple screen resoulution.

here i m adding my xml file

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

following is my graphical layout as i designed

mapview goes to fill parent instead of wrap content

following is the actual layout which i m showing at run time.

mapview goes to fill parent instead of wrap content

can anyone tell me how to come out from this problem?????


To adjust the mapview vertically between 2 layouts i used "height=0dp" and "weight=1" and works fine for me:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜