【问题标题】:Scroll entire page when scrolling list view滚动列表视图时滚动整个页面
【发布时间】:2014-09-30 19:06:55
【问题描述】:

我有以下布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/commentView"
android:orientation="vertical"
android:background="@color/gray" >


<LinearLayout
    android:id="@+id/thumbnail"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/relativeLayout1"
    android:background="@color/white"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:text="O descriere titlu"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ImageView
        android:id="@+id/list_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="5dp"
        android:adjustViewBounds="true"
        android:src="@drawable/lion" />
</LinearLayout>

<ListView
    android:id="@+id/commentList"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/thumbnail"
    android:divider="#b5b5b5"
    android:dividerHeight="1dp"
    android:listSelector="@drawable/list_selector" >

</ListView>

在线性布局中,我加载了半个屏幕图片并使用一些 textView 填充列表视图。我想滚动整个页面,包括滚动 listView 时的图片。 我的意思是,如果我滚动得足够多,我希望列表视图在整个屏幕上展开。 目前,图像始终保持在同一个位置,并且列表视图可在屏幕的一半上滚动。

【问题讨论】:

    标签: android android-layout android-fragments android-listview android-view


    【解决方案1】:

    您可以通过同时覆盖getViewTypeCountgetItemViewType 来在ListView 中包含半屏图片,以根据基础数据列表中的对象类型加载适当的内容。

    猜你喜欢
    • 2023-04-11
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多