1

我想创建列表视图,能够水平和垂直滚动。图像显示列表视图中的行项目。一切都应该作为正常的列表视图 - 垂直滚动的能力。

除了标题( Teszt Elk Nev )行中的其余数据也应该水平滚动。(正如您在图像上看到的 - 第二行)当我水平滚动时,列表视图中的所有行都应该水平滚动,因此所有行都具有相同的水平滚动位置。

在此处输入图像描述

我花了几个小时试图解决它。迄今为止最好的解决方案是水平滚动只有一行。我的行项目布局代码。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/tvOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_marginRight="30dp"
        android:text="one" />

    <com.example.testproject.CustomHorScroll
        android:id="@+id/myHorScroll"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:id="@+id/myLay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="70dp"
                android:text="two" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="70dp"
                android:text="three" />

            <!-- rest items goes here --!>
        </LinearLayout>
    </com.example.testproject.CustomHorScroll>

</LinearLayout>

我想处理水平滚动移动并传播到列表视图中的所有行以设置水平滚动视图.scrollBy(x,0)。但我不能让它工作。:/

另一个想法是跳过列表视图并使用滚动视图和水平滚动创建自定义布局。

4

2 回答 2

0

不幸的是,一般来说,Android 不支持滚动项目中的滚动项目。

您最好的选择可能是使用诸如 ScrollView 或 Horizo​​ntalScrollView 之类的东西,以及其中包含列表(或其他可滚动项)的 LinearLayout:http: //developer.android.com/reference/android/widget/ScrollView.html

于 2013-08-06T19:30:34.723 回答
0

您可能想研究使用两种方式的列表视图库。

https://github.com/lucasr/twoway-view

于 2013-08-06T19:52:41.440 回答