mercredi 6 mai 2015

Fill vertical space between two views (+scroll)

I have 3 views.
1. View A has a fixed height and aligned to the top of the screen.
2. View B has a fixed height and aligned to the bottom of the screen.
3. View C has to fill a vertical space between views A and B but has to be minimum X height. If the vertical space between A and B is less than Xdp, the vertical scroll bar has to appear (and view B has to scroll, not to be sticked to bottom).

What I have so far (a bit simplified), it may be completely wrong:

<ScrollView
    xmlns:android="http://ift.tt/nIICcg"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:fillViewport="true">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:id="@+id/layout_banner_top"
            android:layout_width="match_parent"
            android:layout_alignParentTop="true"
            android:layout_height="@dimen/statistics_probanner_height">

         </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content" <!-- UPD here as McAdam331 suggested -->
            android:minHeight="@dimen/statistics_circular_progress_container_height"
            android:layout_below="@+id/layout_banner_top"
            android:layout_above="@+id/layout_banner_bottom">

            <!-- here is some content -->

         </RelativeLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="@dimen/statistics_bottom_bar_height"
            android:id="@+id/layout_banner_bottom"
            android:layout_alignParentBottom="true">

        </RelativeLayout>
    </RelativeLayout>
</ScrollView>

How it looks:
Picture 1
Picture 2

Currently minHeight of the view in between (view C) is set to 600dp, but as you see on Picture 2 view C is filling an available space between top and bottom views, height is too small and scroll not appearing.

Is it possible to implement? How can I achieve that behaviour?

Aucun commentaire:

Enregistrer un commentaire