2016-03-16 42 views
0

我在我的应用程序中有一个列表视图,我想使其行全屏。如何使全屏列表视图行

我将每件事情都设置为match_parent,但它没有奏效。

它只需要一半的屏幕。

我该如何做到这一点?

这是我的列表视图代码:

<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> 

回答

0

尝试在getView适配器的添加此():

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