【问题标题】:How to use Listview inside Scrollview?如何在 Scrollview 中使用 Listview?
【发布时间】:2015-01-22 14:28:30
【问题描述】:

我有一个父滚动视图和一个列表视图。父滚动视图的属性影响子列表视图的滚动属性。我无法滚动列表视图 只有滚动视图的其他子视图正在滚动。我该如何解决这个问题。

我使用了以下xml:

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/newmenu_layout"
    android:layout_marginBottom="120dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginTop="10dp"
    android:overScrollMode="never"
    android:scrollbars="none" >

    <LinearLayout
        android:id="@+id/edit_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <ListView
            android:id="@+id/ImageList"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:scrollbars="none" >
        </ListView>

        <RelativeLayout
            android:id="@+id/videodetail"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edt_stroke_bg"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/img"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:background="@drawable/video_notes" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:layout_toRightOf="@+id/img"
                android:text="@string/videoattach" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/audiodetail"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edt_stroke_bg"
            android:orientation="horizontal"
            android:visibility="gone" >

            <ImageView
                android:id="@+id/imgaudio"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:background="@drawable/audio_notes" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:layout_toRightOf="@+id/imgaudio"
                android:text="Audio attachment" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/drawingdetail"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edt_stroke_bg"
            android:orientation="horizontal"
            android:visibility="gone" >

            <ImageView
                android:id="@+id/drawing_img"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:background="@drawable/video_notes" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="5dp"
                android:layout_toRightOf="@+id/drawing_img"
                android:text="Drawing attachment" />
        </RelativeLayout>

        <LinearLayout
            android:id="@+id/edt_check"
            android:layout_width="fill_parent"
            android:layout_height="150dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/edt_stroke_bg"
            android:orientation="vertical"
            android:paddingStart="5dp" >

            <EditText
                android:id="@+id/body"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="@android:color/transparent"
                android:gravity="top"
                android:imeOptions="actionDone"
                android:paddingLeft="10dp"
                android:paddingRight="5dp"
                android:paddingTop="5dp" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>

是否有任何列表视图或任何侦听器的属性来解决问题?提前致谢。

【问题讨论】:

标签: android xml listview scroll scrollview


【解决方案1】:

您的设计不正确。您永远不应该将ListView 放在ScrollView 中。 ListView 实现了它自己的滚动,它不会收到任何手势,因为它们是由ScrollView 处理的。它不会工作。

【讨论】:

  • K.然后给出一些想法。我在一个活动中有 3 个不同的列表视图。每个列表都应显示完整的内容列表。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-12
  • 2021-05-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多