Android 当屏幕上出现新视图时,如何使视图调整大小/缩短自身?

Android 当屏幕上出现新视图时,如何使视图调整大小/缩短自身?,android,google-maps,android-layout,android-fragments,Android,Google Maps,Android Layout,Android Fragments,我在屏幕上有两个视图,一个谷歌地图片段和一个不同的自定义片段。在自定义片段出现在屏幕上之前,谷歌地图是全屏的,这很好。一旦新片段出现在屏幕底部,我希望谷歌地图能够调整大小,以便它只占用新片段未使用的可用空间 即在新片段之前 |----------------| | | | | | | | | | Map | | | |

我在屏幕上有两个视图,一个谷歌地图片段和一个不同的自定义片段。在自定义片段出现在屏幕上之前,谷歌地图是全屏的,这很好。一旦新片段出现在屏幕底部,我希望谷歌地图能够调整大小,以便它只占用新片段未使用的可用空间

即在新片段之前

|----------------|
|                |
|                |
|                |
|                |
|      Map       |
|                |
|                |
|                |
|                |
|                |
|                |
|----------------|
|----------------|
|                |
|                |
|                |
|      Map       |
|                |
|                |
|                |
|----------------| <-- Map ends here
|                |
|  New Fragment  |
|                |
|----------------|
新片段之后

|----------------|
|                |
|                |
|                |
|                |
|      Map       |
|                |
|                |
|                |
|                |
|                |
|                |
|----------------|
|----------------|
|                |
|                |
|                |
|      Map       |
|                |
|                |
|                |
|----------------| <-- Map ends here
|                |
|  New Fragment  |
|                |
|----------------|
|----------------|
|                |
|                |
|                |
|地图|
|                |
|                |
|                |

|----------------|听起来是使用
LinearLayout
layou-weight
属性的好时机

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        tools:context="com.example.damia.placefinder.activities.MapsActivity"/>

    <FrameLayout
        android:id="@+id/container_locations"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:background="@color/cardview_light_background"
        android:visibility="gone">

    </FrameLayout>

</LinearLayout>