Android 线性布局中的可变高度

Android 线性布局中的可变高度,android,android-linearlayout,Android,Android Linearlayout,我希望得到以下信息: 我希望滚动视图在顶部始终为50%或更大。。这取决于底部的列表视图。listview将根据其拥有的项目数量最多为50% 有人知道怎么得到这个吗? 我一直在尝试一些关于宽度/高度和重量的东西。。但无法找到解决方案。。他们都没有找到stackoverflow的解决方案 基本设置: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://sc

我希望得到以下信息: 我希望滚动视图在顶部始终为50%或更大。。这取决于底部的列表视图。listview将根据其拥有的项目数量最多为50%

有人知道怎么得到这个吗? 我一直在尝试一些关于宽度/高度和重量的东西。。但无法找到解决方案。。他们都没有找到stackoverflow的解决方案

基本设置:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/LinearLayout1"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   tools:context=".RouteGroupDetailActivity" >

    <ScrollView
       android:id="@+id/scrollView1"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:layout_weight="1">

        <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="match_parent" >
        </LinearLayout>
    </ScrollView>

    <ListView
       android:id="@+id/listView1"
       android:layout_width="match_parent"
       android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>


首先-这是一个非常奇怪的要求,但如果您想继续,我会在ScrollView和ListView上都放置layout\u height=“match\u parent”,在ListView上放置layout\u weight=“1”。如果ListView中有X个以上的项目,只需通过编程在ScrollView上添加layout_weight=“1”。当我删除layout_weight时,我再也看不到ListView了……这是因为您已将match_parent添加到ScrollView。如果您想使用更简单的方法,只需将layout\u height=“match\u parent”和layout\u weight=“1”添加到两个元素中即可。您可以通过编程更改布局和重量,使一个元素占用更多空间。谢谢您的建议。但是我等待了一段时间,等待是否有人知道不计算列表视图高度的方法。这必须是可能的。还有奇怪的要求。如果客户不提出奇怪的问题,这会容易得多。@kape123你能通过程序发布你的anwser吗?毕竟这是最简单的方法。。我愿意接受它。