2

I have the following 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 >

And the map is show in almost the full screen size and the text view is show just by half.

How can I make to the map fill just the free space in the screen? Letting enough space for the others views?

4

1 回答 1

5

Make android:layout_height="0dp" on the <fragment>, and remove the android:layout_weight attribute from the TextView. Then, the TextView will get its natural height, and the map will take up the remaining space.

That being said, you will probably want a top margin on the TextView, so the map does not run right into your text.

于 2013-06-09T18:22:46.200 回答