0

我在相对布局中具有 2 个列表视图 1 的布局,如下所示

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

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

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

</RelativeLayout>

因此,根据添加的视图,根据客户设计,第二个列表视图被放置在第一个列表视图之上。

现在我的要求是我想要第二个列表视图,即上面放置的列表视图是固定的,下面放置的列表视图应该是可滚动的,因为第一个列表视图最多有 5 个项目。目前它发生的情况与此完全相反。我试过了

android:focusable="false" android:clickable="false"

但没有运气。请帮助我解决这个问题或告诉我任何其他方法

4

3 回答 3

2

您可能还必须提供 ListView match_parent 的高度。考虑对第一个列表使用 LinearLayout,因为您知道最多有 5 个项目。

此外,您似乎没有使用 RelativeLayout 属性来设置默认情况下与顶部和左侧对齐的子视图的位置。考虑使用 FrameLayout 将其切换出来。

于 2013-11-13T19:48:21.303 回答
0

像这样试试。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity"
    android:orientation="vertical" >

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

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

</LinearLayout>

如果我输入 5 个最大值,这对我有用,listView1那么它不会滚动并且下面会listView2滚动。

于 2013-11-13T20:09:55.280 回答
0

尝试这个

    <ListView
        android:id="@+id/listView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:clickable="false" >

    </ListView>
    <ListView
        android:clickable="true"
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</RelativeLayout>
于 2013-11-14T03:25:23.537 回答