yurong1024 / android-wheel

Automatically exported from code.google.com/p/android-wheel
0 stars 0 forks source link

Width of Wheel calculated on visible elements at time of creation. #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a wheel with multiple elements some with a width of 2-3 char, some 
with a width of 12 char
2. Set the wheel up such that on creation only elements of width 2-3 char are 
visible

What is the expected output? What do you see instead?
The width of the wheel should match the width of the widest view in the series 
of elements.  Instead the width matches the widest view visible at the time of 
creation of the wheel

What version of the product are you using? On what operating system?
2.1  on Android 2.2.

Please provide any additional information below.

I think I should be able to provide a patch but have not completed it as of 
this stage.  

I believe the desired functionality can be achieved by changing  
calculateLayoutWidth(int widthSize, int mode) to loop through the elements of 
viewAdapter and using the maximum value for width from all elements of the 
adapter rather than itemsLayout.getMeasuredWidth().  

Original issue reported on code.google.com by mike.hi...@gmail.com on 25 Mar 2011 at 7:11

GoogleCodeExporter commented 9 years ago
Hi Mike,

I was thinking about this issue.
There are next solutions:
 1) use the way you described, but it will work so slowly in case there are thousands/millions wheel elements.
 2) calculate the width each time elements are changed, to be as long as the longest visible item. In this case the wheel will be "dancing"
 3) use the same width for all wheel items
 4) specify the wheel width manually

I think, the 1st and 2nd ways are not good.
If you know the wheel contains not too much items the 1st way is acceptable.
This functionality can be moved to separated method that can be overridden by 
subclasses.

Original comment by yuri.kan...@gmail.com on 31 Mar 2011 at 11:22

GoogleCodeExporter commented 9 years ago
Hi,

I would suggest option 2 where the size can only grow + an option to manually 
force-set the initial width (option 3).

Original comment by oferr.em...@gmail.com on 1 Apr 2011 at 6:37

GoogleCodeExporter commented 9 years ago
This bug can be seen even in the Demo Wheel application:

Open the "time 2" example and scroll the hour wheel all the way down.

Original comment by andreas....@gmail.com on 13 Sep 2011 at 12:46

GoogleCodeExporter commented 9 years ago
Any suggestions for getting around this? I am hoping to use the Wheel in a 
similar fashion as Time2-example. How can I force each item to be visible, 
somehow forcing the hour wheel (in my case 0->23) to the width of the "23"-item?

Original comment by asmo.soi...@gmail.com on 29 Nov 2011 at 5:03

GoogleCodeExporter commented 9 years ago
Just found one simple workaround: just set the width of the hours-item 
manually, instead of "wrap_content".

Original comment by asmo.soi...@gmail.com on 29 Nov 2011 at 5:06

GoogleCodeExporter commented 9 years ago
Yuri, both JList and JComboBox in Swing solved this problem by letting you 
define a "prototype" value that is used to compute the cell width: the 
framework doesn't know what would be good width but the programmer often does! 
That would be a special case of your option 3). That works very well for us 
Swing programmers; no need to complicate things.

Original comment by lefev...@gmail.com on 5 Feb 2012 at 2:58