Listview的Android高度与父LinearLayout不匹配

Listview的Android高度与父LinearLayout不匹配,android,listview,xamarin,Android,Listview,Xamarin,我的axml中有以下代码: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android" p1:layout_width="fill_parent" p1:layout_height="fill_parent" p1:background="@android:color/white"> <ScrollView

我的axml中有以下代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:p1="http://schemas.android.com/apk/res/android"
p1:layout_width="fill_parent"
p1:layout_height="fill_parent"
p1:background="@android:color/white">
<ScrollView
    p1:layout_width="match_parent"
    p1:layout_height="match_parent"
    p1:layout_weight="1"
    p1:paddingLeft="16dp"
    p1:paddingRight="16dp"
    p1:scrollbarStyle="outsideOverlay"
    p1:background="#ffffffff"
    p1:id="@+id/scrollView1">
    <LinearLayout
        p1:orientation="vertical"
        p1:minWidth="25px"
        p1:minHeight="25px"
        p1:layout_width="match_parent"
        p1:layout_height="match_parent"
        p1:id="@+id/linearLayout1">
        <TableLayout
            p1:minWidth="25px"
            p1:minHeight="25px"
            p1:layout_width="match_parent"
            p1:layout_height="wrap_content"
            p1:id="@+id/tableLayout1"
            p1:stretchColumns="*">
            <TableRow
                ...
            </TableRow>
        </TableLayout>
        <ListView
            p1:minWidth="25px"
            p1:id="@+id/lvPositions"
            p1:layout_width="match_parent"
            p1:layout_height="0dp"
            p1:layout_weight="1" />
    </LinearLayout>
</ScrollView>
</RelativeLayout>


可能是因为您在ScrollView中使用了ListView,这可能会造成麻烦,您可以尝试摆脱ScrollView。

为什么不使用布局高度来匹配父视图?在某些情况下,您应该为父视图的所有子视图定义权重。@MohamamdFatemi我以前做过,但没有成功。您是否尝试更改listView的高度以包装内容?@YawAsare我尝试过,但没有work@MoProg更改scrollview的布局高度以包装内容并检查其是否有效?是的,你是对的。在删除scrollview和RelativeLayout以及一些小更改之后,它终于起作用了。谢谢