如何使SupportMapFragment不填充屏幕高度

jon*_*nrz 2 android android-layout

我有以下布局:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        class="com.google.android.gms.maps.SupportMapFragment" />

    <TextView 
        android:text="Teste"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

</LinearLayout >
Run Code Online (Sandbox Code Playgroud)

并且地图几乎以全屏尺寸显示,文本视图仅显示一半.

如何在地图中填充屏幕中的可用空间?为其他人提供足够的空间观点?

Com*_*are 5

制作android:layout_height="0dp"<fragment>,然后取出android:layout_weight从属性TextView.然后,TextView将获得其自然高度,地图将占用剩余空间.

话虽这么说,你可能会想要一个上边距TextView,所以地图不会直接进入你的文本.