[英]Horizontal scroll in android listView
I want to create list view, with ability to scrool horizontaly and vertically. 我想创建列表视图,并具有水平和垂直方向上的功能。 Image shows row item from list view.
该图显示了列表视图中的行项目。 Everything should act as normal list view - ability to scroll verticaly.
一切都应充当普通列表视图-能够垂直滚动。
Besides Title ( Teszt Elk Nev ) rest data in row should also scrool horizontaly. 除标题(Teszt Elk Nev)外,行中的其余数据也应水平排列。 ( as you can see on image - second row ) When I scroll horizontaly all rows in list view should scrool horizontaly, so all rows has the same horizontaly scrool position.
(如您在图像上看到的-第二行)当我水平滚动时,列表视图中的所有行都应为scrool水平,因此所有行的scrool位置均相同。
I spent few hours try to solve it. 我花了几个小时尝试解决它。 Best solution so far is horizontal scrool only one row.
迄今为止最好的解决方案是将水平山cro酚仅排成一排。 My code for row item layout.
我的行项目布局代码。
<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>
I want to handle horizontal scrool movement and propagate to all row in listview to set horizontalscroolView.scrolBy(x,0). 我想处理水平scrool运动并传播到listview中的所有行,以设置horizontalscroolView.scrolBy(x,0)。 But I can't make it works.
但是我不能使它起作用。 :/
:/
Another idea is to skip listview and create custom layout with scroll view and horizontalScroll. 另一个想法是跳过listview并使用滚动视图和horizontalScroll创建自定义布局。
Unfortunately, Android doesn't support scrolling items within scrolling items generally speaking. 不幸的是,Android通常不支持滚动项中的滚动项。
Your best bet is probably to use something such as a ScrollView or a HorizontalScrollView, and a LinearLayout containing lists (or other scrollable items) inside of that: http://developer.android.com/reference/android/widget/ScrollView.html 最好的选择可能是使用诸如ScrollView或HorizontalScrollView之类的东西,以及其中包含列表(或其他可滚动项)的LinearLayout: http : //developer.android.com/reference/android/widget/ScrollView.html
You probably want to look into use the two way listview library. 您可能想研究使用两种方式的listview库。
https://github.com/lucasr/twoway-view https://github.com/lucasr/twoway-view
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.