Resizing layouts dynamically with ViewFlipper
Asked Answered
G

1

14

I have a layout sizing issue...

I have a layout which consists of a ViewFlipper, a LinearLayout (containing a MapView), and a 2nd LinearLayout all in a vertical row.

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

The problem I'm seeing is that when I change the ViewFlipper to show a shorter view with showNext() or showPrevious(), the middle LinearLayout does not expand to fill the space. Also, I see black/empty space left over from the previous ViewFlipper view when I change to a shorter view.

Is there a slick way to dynamically resize these elements so that the MapView layout will expand to fill all space not occupied by the ViewFlipper and bottom LinearLayout?

Gaige answered 7/12, 2012 at 4:21 Comment(1)
did you found the solution for this blank space?Haifa
S
26

Try to add android:measureAllChildren="false" to your ViewFlipper

<ViewFlipper
     android:width="match_parent"
     android:height="wrap_content"
     android:measureAllChildren="false" >
<!-- Top elements --> 
</ViewFlipper>
Superfluous answered 30/11, 2015 at 12:34 Comment(1)
In our cases, this is also fix our blank space issue even after navigating between ViewFlipper with showPrevious() and showNext()Haifa

© 2022 - 2024 — McMap. All rights reserved.