Android ListView内部的相对布局

Android ListView内部的相对布局,android,listview,xamarin,adapter,android-relativelayout,Android,Listview,Xamarin,Adapter,Android Relativelayout,我有以下Relativelayout,其中包含带标签的线性布局。此Relativelayout已推送到自定义适配器中的自定义ListView。我本想一个接一个地去看亲戚,但结果却失败了 将列表上方文本视图的高度设置为wrap\u content为了解决我的问题,我使用了LQ Gioan的建议,并用weightSum属性将目标GridLayout替换为LinearLayout。在内容元素中,我使用layout\u-weight属性 <LinearLayout xmlns:android="

我有以下Relativelayout,其中包含带标签的线性布局。此Relativelayout已推送到自定义适配器中的自定义ListView。我本想一个接一个地去看亲戚,但结果却失败了



将列表上方文本视图的高度设置为
wrap\u content

为了解决我的问题,我使用了LQ Gioan的建议,并用weightSum属性将目标GridLayout替换为LinearLayout。在内容元素中,我使用layout\u-weight属性

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="100">
<TextView
        android:text="Список водомеров"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_weight="11"
        android:id="@+id/textView1" />


为什么不使用recyclerView,这是解决问题的最佳方法。试着看一下,你会明白的。我认为这个问题是由ListView上面的TextView引起的。您应该在开发人员选项中启用“显示布局绑定”功能,以便可以看到导致问题的视图。访问此处了解如何启用“显示布局绑定”:。希望如此help@LQGioan是的,这是coll tip。现在看来,我的行已经添加到了TextView,而不是ListView是的,这在我们开发布局时非常有用。在使用<代码> App:LayOutyRoWosix=“XXX”< /C>时应考虑。根据您的目标,您应该使用另一种方法来完成此操作。您可以更新您的问题(包括答案),以便其他有相同问题的人可以快速解决他们的问题
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:columnCount="1"
    app:rowCount="7">
    <TextView
        android:text="Список водомеров"
        android:layout_width="match_parent"
        app:layout_rowWeight="0.05"
        android:gravity="center_horizontal"/>
    <ListView
        android:minWidth="25px"
        android:minHeight="25px"
        app:layout_rowWeight="0.3"
        android:layout_width="match_parent"
        android:choiceMode="singleChoice" />
    <TextView
        android:text="Введите показания водомера"
        app:layout_rowWeight="0.02"
        android:layout_width="match_parent"
        android:gravity="center" />
    <EditText
        android:inputType="number"
        app:layout_rowWeight="0.04"
        android:layout_width="match_parent"/>
    <Button
        android:text="Сделать фото"
        android:textSize="20dp"
        app:layout_rowWeight="0.02"
        android:layout_width="match_parent"
        android:gravity="center"/>
    <Button
        android:text="Отправить показания"
        android:textSize="24dp"
        app:layout_rowWeight="0.15"
        android:layout_width="match_parent"
        android:gravity="center"/>
    <Space
        app:layout_rowWeight="0.3" />
</android.support.v7.widget.GridLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="100">
<TextView
        android:text="Список водомеров"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:layout_weight="11"
        android:id="@+id/textView1" />