Android:是否不可能有一个包含listview元素的混合屏幕?

Android:是否不可能有一个包含listview元素的混合屏幕?,listview,android-layout,Listview,Android Layout,可能是一个布局文件可以解释我在说什么 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >

可能是一个布局文件可以解释我在说什么

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


<ListView
    android:id="@+id/listview"
    android:layout_width="match_parent"
    android:layout_height="400dp" />



<LinearLayout
    android:id="@+id/sublayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

  <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/text_btn1"
    android:onClick="select" />


  <Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/text_btn2"
    android:onClick="select2" />

</LinearLayout>

如您所见,linearlayout充当根布局元素

我想要的是80%屏幕的列表视图,接下来20%的屏幕将由其他元素组成,例如按钮。在android中不可能做到这一点吗?如果是,我应该使用哪个属性


提前感谢。

我认为解决方案使用的是
android:layout\u weight
,因此您可以指定多个视图之间的大小比率。 试试这个:

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


<ListView
    android:id="@+id/listview"
    android:layout_width="fill_parent"
    android:layout_height="0dp" 
    android:layout_weight="80"/>



<LinearLayout
    android:id="@+id/sublayout"
    android:layout_width="fill_parent"
    android:layout_height="0dp" 
    android:layout_weight="20">

 <Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/text_btn1"
    android:onClick="select" />


 <Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/text_btn2"
    android:onClick="select2" />

</LinearLayout>
</LinearLayout>