如何在安卓中获取水平和垂直可滚动列表



我正在开发一个Android应用程序,其中显示按天的频道时间表(多行)。现在,我必须同时提供垂直和水平滚动。垂直可滚动性是正常的,但水平滚动性应该是同步的也就是说,当用户水平滚动时,所有其他行也应该在同步中滚动。

我尝试使用表格布局,但它不符合我的要求,我也尝试了 TwoWayView,但我无法同步水平滚动。

想知道我有人遇到/解决了类似的情况。

对此的任何线索都非常赞赏。

用于垂直和水平滚动的xml:-

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/vertical_scroll_view2">
    <HorizontalScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/horizontal_scroll_view2">
    <LinearLayout
        android:layout_height="wrap_content"
        android:layout_width="910dp"
        android:id="@+id/scheduleContainer"
        android:orientation="vertical"
        />
    </HorizontalScrollView>

</ScrollView>

.....双向视图的XML:-

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView
        android:id="@+id/weekday"
        android:layout_height="fill_parent"
        android:layout_width="40dp"
        android:textSize="12dp"
        android:textStyle="bold" />
    <com.mobiotics.tvb_stb.utilityclasses.TwoWayView
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/hlist"
        style="@style/TwoWayView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_toRightOf="@id/weekday"
        android:scrollbars="none"
        android:drawSelectorOnTop="false"
        tools:context="com.mobiotics.tvb_stb.activity.HomeScreenActivity" />
</RelativeLayout>

我正在将双向列表添加到线性布局中。

如果你能有一个ListView,我会从那里开始。 只需将列表视图拖放到水平滚动视图中即可。 确保将水平滚动视图的宽度设置为 wrap_content。 我注意到您将其设置为fill_parent。

最新更新