【问题标题】:Android ListView and Scroll problemAndroid ListView 和 Scroll 问题
【发布时间】:2011-02-01 21:06:00
【问题描述】:

我有一个LinearLayout,其中有多个TextView,底部是ListView - 请参见下面的代码。

问题是 TextView/CheckBox 占据了大约 75% 的屏幕 - ListView 然后在底部有一个滚动,不能大量使用 - 我如何禁用 ListView 滚动并启用整个 LinearLayout 滚动。请提供一些示例代码。

<LinearLayout android:orientation="vertical"
    android:layout_margin="5dip"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <RelativeLayout android:layout_width="fill_parent"
        android:layout_margin="5dip"
        android:layout_height="wrap_content"
        android:background="#CCCCCC">
        <TextView android:id="@+id/_text_title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/text1"
            android:layout_marginTop="14dip"
            android:textColor="#FFFFFF"
            android:gravity="center_horizontal"
            android:textSize="17dip"
            android:textStyle="bold" />

           <CheckBox ..../>
           <CheckBox ..../>
           <TextView android:id="@+id/_text_title" ..../>
           <CheckBox ..../>
           <CheckBox ..../>
       <ListView .../>
</LinearLayout>

【问题讨论】:

  • 你的活动是 ListActivity 吗?
  • 两者都可以,但目前它是一个活动。

标签: android listview scroll


【解决方案1】:

切勿将可滚动视图放在另一个可滚动视图中。不起作用。如果你遇到这样的问题,你就有一个 UI 设计缺陷。 UI 重新设计/重新思考迫在眉睫。

【讨论】:

    【解决方案2】:

    好的,所以我找到了解决方案。

    我手头没有代码,但大致来说我所做的是,

    1. 创建扩展 ListView 的新类
    2. 覆盖 onMeasure 方法,
    3. 使用我拥有的数据集 - 我知道每一行的高度,我计算列表的高度并手动设置。

    【讨论】:

      【解决方案3】:

      我也遇到了同样的问题。要删除它,您必须将列表视图放在 sap rate 布局中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多