Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resizing layouts dynamically with ViewFlipper

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?

like image 807
TomBomb Avatar asked Dec 07 '12 04:12

TomBomb


1 Answers

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

<ViewFlipper
     android:width="match_parent"
     android:height="wrap_content"
     android:measureAllChildren="false" >
<!-- Top elements --> 
</ViewFlipper>
like image 197
Mykhailo Yuzheka Avatar answered Oct 20 '22 03:10

Mykhailo Yuzheka