小编use*_*232的帖子

Android列表视图项高度fill_parent不起作用

我有一个带有main活动的Android应用程序,其中包含listview,这是主要活动布局的代码:

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

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

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在listview中我显示了一个局部视图,这是视图布局的代码:

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

    <TextView
        android:id="@+id/commandText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我希望元素填充mainactivitylayout的高度,但结果是: 结果图像在此输入图像描述

谢谢你的问候

height android listview fill

2
推荐指数
1
解决办法
3543
查看次数

标签 统计

android ×1

fill ×1

height ×1

listview ×1