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?

TomBomb
  • 3,236
  • 5
  • 31
  • 40

1 Answers1

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>
Pranav Karnik
  • 3,318
  • 3
  • 35
  • 47
Mykhailo Yuzheka
  • 713
  • 1
  • 7
  • 24
  • 1
    In our cases, this is also fix our blank space issue even after navigating between ViewFlipper with `showPrevious()` and `showNext()` – mochadwi Oct 01 '20 at 10:35