如何在垂直布局中制定最大和最小高度?

How to develop a maximum and minimum heigh in a vertical layout?

我想开发这个设计:

上层布局有一个最大高度,如果超过这个高度:显示滚动条。并且底部布局有一个最小高度,它与上部布局的底部对齐

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="5"
        android:orientation="vertical">
        <RelativeLayout
            android:layout_weight="2"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <ScrollView
                android:id="@+id/scrollView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:fillViewport="true"
                android:scrollbarStyle="insideInset" >
                <TextView android:id="@+id/quest_question_text"
                    android:padding="5sp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/rectangle_quest"
                    style="@style/entry_style"/>
            </ScrollView>
        </RelativeLayout>   

        <RelativeLayout
            android:layout_weight="3"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <ListView 
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/answer_list"/>
        </RelativeLayout>
    </LinearLayout>

感谢您的宝贵时间!

可能有一种方法可以根据上层布局的大小来设置相对布局的权重。

我能想到的最好的方法就是使用这种布局。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fillViewport="true"
    android:scrollbarStyle="insideInset" >

    <TextView
        android:id="@+id/quest_question_text"
        style="@style/entry_style"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/rectangle_quest"
        android:padding="5sp" />
</ScrollView>

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

    <ListView
        android:id="@+id/answer_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</RelativeLayout>
</LinearLayout>

创建视图时获取设备的高度并设置滚动视图的最小高度。

scrollView.setMinimumHeight(Height / 2);  <--- for 50%