老虎机不尽的名单如何获得对准线 [英] Slot machine with endless list how to get aligned lines

查看:150
本文介绍了老虎机不尽的名单如何获得对准线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现与3无尽的ListView插槽MACHIN。我想做到这一点与滚动的看法,但我没有找到一个滚动视图解决循环。

I'm trying to implement a slot machin with 3 endless ListView. I wanted to do that with scroll view but I didn't find a solution to loop on a scrollView.

所以基本上,我有三个列表视图= 3我的老虎机列,当我点击按钮,我想滚动到一个随机位置(之间的随机整数0(含)和300(不含)这是我的列表大小)

So basically I have three listview = 3 columns of my slot machine and when I click on button I want to scroll to a random position (a random integer between 0 (inclusive) and 300 (exclusive) which is my lists size) :

Random r = new Random();
int rPos1 = r.nextInt(300 - 0) +0;
int rPos2 = r.nextInt(300 - 0) + 0;
int rPos3 = r.nextInt(300 - 0) +0;

listSlotOne.smoothScrollToPosition(rPos1);
listSlotTwo.smoothScrollToPosition(rPos2);
listSlotThree.smoothScrollToPosition(rPos3);

因此​​,所有这部分工作,但我不能管理每次显示结果一个干净的结果是我的屏幕:

So all this part is working but I can't manage to display each time as a result a clean result which mean three aligned lines on my screen ::

这里了良好的效果:三线对齐

在这里输入的形象描述

在这里,一个坏的结果:行没有对齐

在这里输入的形象描述

是否有可能来管理我的随机滚动的行为,以显示每一次不错的结果:三对准线
我注意到,我的3点击播放按钮,我有一个很好的结果,但第四个点击后,我得到一个错误的结果与线条没有对齐,那么它是随机的。

Is it possible to manage the behaviour of my random scroll to display every time a good result : three aligned lines. I've noticed, for my 3 click on the play button I got a good result but after a fourth click I get a wrong result with not lines aligned and then it's random.

推荐答案

如果该smoothScrollToPosition()方法不捕捉,你将不得不增加自己的管理单元意思是这样的:

If the smoothScrollToPosition() method doesn't snap, you are going to have to add your own snap meaning something like:

listSlotOne.smoothScrollToPosition((rPos1 % snap_height) * snap_height);
listSlotTwo.smoothScrollToPosition((rPos2 % snap_height) * snap_height);
listSlotThree.smoothScrollToPosition((rPos3 % snap_height) * snap_height);


    listSlotOne.smoothScrollToPosition((rPos1 / snap_height)* snap_height);
    listSlotTwo.smoothScrollToPosition((rPos2 / snap_height)* snap_height);
    listSlotThree.smoothScrollToPosition((rPos3 / snap_height)* snap_height);

or listSlotOne.smoothScrollToPosition((rPos1 / snap_height) * snap_height); listSlotTwo.smoothScrollToPosition((rPos2 / snap_height) * snap_height); listSlotThree.smoothScrollToPosition((rPos3 / snap_height) * snap_height);

我可能是错的,我不是100%肯定,但我相信,这将解决您的问题。

I may be wrong, I'm not 100% sure but I believe that will solve your problem.

对齐网格
我记得有MOD做虽然...好也许这会有所帮助。

Snap To Grid I remember doing it with MOD though... well maybe this will help.

干杯,
结果
Demetry

Cheers,
Demetry

这篇关于老虎机不尽的名单如何获得对准线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆