如何制作全屏listview行

如何制作全屏listview行,listview,fullscreen,Listview,Fullscreen,我的应用程序中有一个listview,我想让它的行全屏显示 我把每件事都设置成和你的父母相匹配,但没用 它只占屏幕的一半 我该怎么做 这是我的listview代码: <ListView android:id="@+id/listviewFactoriPortfolio" android:layout_width="match_parent" android:layout_height="match_parent" > </ListView>

我的应用程序中有一个listview,我想让它的行全屏显示

我把每件事都设置成和你的父母相匹配,但没用

它只占屏幕的一半

我该怎么做

这是我的listview代码:

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

这是我对每一行的自定义布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:background="#FFFFFF"
android:gravity="center"
android:orientation="vertical"
android:padding="5dp" >

<ImageView
    android:id="@+id/imgImageItem"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="5dp"
    android:padding="5dp"
    android:scaleType="fitXY"
    android:src="@drawable/photo_2" />

<TextView
    android:id="@+id/txtNameItem"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_margin="5dp"
    android:gravity="center"
    android:padding="5dp"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/txtExplainItem"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txtNameItem"
    android:layout_margin="5dp"
    android:gravity="center"
    android:padding="5dp"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/txtCostItem"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/imgImageItem"
    android:layout_alignParentBottom="true"
    android:layout_margin="5dp"
    android:gravity="center"
    android:padding="5dp"
    android:text="Small Text"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
    android:id="@+id/txtDestributeDateItem"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/txtCostItem"
    android:layout_margin="5dp"
    android:gravity="center"
    android:padding="5dp"
    android:text="Small Text"
    android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
    android:id="@+id/txtAddressItem"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/txtDestributeDateItem"
    android:layout_margin="5dp"
    android:gravity="center"
    android:padding="5dp"
    android:text="Small Text"
    android:textAppearance="?android:attr/textAppearanceSmall" />

</RelativeLayout>

尝试在适配器的getView()中添加以下内容:

view.getLayoutParams().height = viewGroup.getHeight() / getCount();
view.requestLayout();