14

我有一个布局大小问题...

我有一个布局,它由一个 ViewFlipper、一个 LinearLayout(包含一个 MapView)和一个垂直行中的第二个 LinearLayout 组成。

<LinearLayout
    android:width="match_parent"
    android:height="match_parent" >

    <ViewFlipper
        android:width="match_parent"
        android:height="wrap_content" >
        // Top elements
    </ViewFlipper>

    <LinearLayout
        android:width="match_parent"
        android:height="match_parent" >
        // MapView
    </LinearLayout>

    <LinearLayout
        android:width="match_parent"
        android:height="wrap_content" >
        // Bottom elements
    </LinearLayout>

</LinearLayout>

我看到的问题是,当我使用 showNext() 或 showPrevious() 更改 ViewFlipper 以显示较短的视图时,中间的 LinearLayout 不会扩展以填充空间。此外,当我更改为较短的视图时,我会看到前一个 ViewFlipper 视图留下的黑色/空白空间。

有没有一种巧妙的方法来动态调整这些元素的大小,以便 MapView 布局将扩展以填充 ViewFlipper 和底部 LinearLayout 未占用的所有空间?

4

1 回答 1

25

尝试添加android:measureAllChildren="false"到您的 ViewFlipper

<ViewFlipper
     android:width="match_parent"
     android:height="wrap_content"
     android:measureAllChildren="false" >
<!-- Top elements --> 
</ViewFlipper>
于 2015-11-30T12:34:10.687 回答