我想创建列表视图,能够在水平和垂直方向上进行水平扫描。 该图显示了列表视图中的行项。 一切都应该作为正常的列表视图 - 滚动verticaly的能力。
除了标题(Teszt Elk Nev)之外,行中的休息数据也应该是水平的。 (正如你在图像上看到的那样 - 第二行) 当我按水平滚动时,列表视图中的所有行都应该是水平的,因此所有行都具有相同的水平位置。
我花了几个小时尝试解决它。到目前为止最好的解决方案是水平scrool只有一行。 我的行项目布局代码。
<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>
我想处理水平scrool移动并传播到listview中的所有行以设置horizontalscroolView.scrolBy(x,0)。 但我不能让它奏效。 :/
另一个想法是跳过listview并使用scroll view和horizontalScroll创建自定义布局。
答案 0 :(得分:0)
不幸的是,Android一般不支持在滚动项目中滚动项目。
您最好的选择可能是使用ScrollView或HorizontalScrollView以及包含列表(或其他可滚动项目)的LinearLayout:http://developer.android.com/reference/android/widget/ScrollView.html
答案 1 :(得分:0)
您可能希望使用双向列表视图库。