dilippaudyal / android-wheel

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

WheelView does not scroll if it is inside a ScrollView #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Add a WheelView below a ScrollView

What is the expected output? What do you see instead?
It should be possible to still move the WheelView. However, it does not change.

What version of the product are you using? On what operating system?
1.4

Please provide any additional information below.

Original issue reported on code.google.com by Achim.Le...@googlemail.com on 3 Dec 2010 at 8:33

GoogleCodeExporter commented 8 years ago
I encountered the same issue now. THere are so many screen sizes to consider 
for android. k!

Original comment by Qixing...@gmail.com on 28 Dec 2010 at 12:50

GoogleCodeExporter commented 8 years ago
I also have the same problem on 2.1.

Original comment by swepi...@gmail.com on 28 Dec 2010 at 7:41

GoogleCodeExporter commented 8 years ago
I have the same problem however I have noticed you can get it to scroll a small 
amount if carefully clicking in the values. It looks like the focus is getting 
lost.

Original comment by PMCro...@gmail.com on 29 Dec 2010 at 1:00

GoogleCodeExporter commented 8 years ago
It also happens when the wheel is inside a group of linearlayouts.
Motorola Milestone running Cyanogenmod 6 (Froyo)
Unfortunately makes the view unusable. Waiting for a fix

Thanks for this great widget

Original comment by gsim...@gmail.com on 18 Jan 2011 at 1:18

GoogleCodeExporter commented 8 years ago
gsimoes,

Could you please provide example with a group of linear layouts?

Thanks

Original comment by yuri.kan...@gmail.com on 18 Jan 2011 at 2:48

GoogleCodeExporter commented 8 years ago
I've fix this issue (I hope).
Please look at 
http://android-devblog.blogspot.com/2011/01/scrolling-inside-scrollview.html
I'm not able to commit the fix now because of working on another issue, will do 
that later. So, please update your sources manually as described in link above 
and let me know whether it works.

Thanks,
Yuriy

Original comment by yuri.kan...@gmail.com on 18 Jan 2011 at 8:58

GoogleCodeExporter commented 8 years ago
Unfortunately it didn´t solve my problem.

Layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_height="wrap_content" android:layout_width="fill_parent">
<TextView android:layout_height="wrap_content" android:textColor="#FFFFFF" 
android:layout_centerHorizontal="true" android:layout_marginTop="5dip" 
android:id="@+id/tvTitle" android:textSize="16sp" android:text="Start Marker" 
android:layout_width="fill_parent" 
android:gravity="center_horizontal"></TextView>

<LinearLayout android:layout_height="wrap_content" 
android:layout_centerHorizontal="true" android:layout_width="wrap_content" 
android:layout_below="@+id/tvTitle" android:layout_marginTop="10dip" 
android:id="@+id/llWheels">
    <LinearLayout android:layout_toLeftOf="@+id/wvHH" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/llHH" android:orientation="vertical">
        <kankan.wheel.widget.WheelView android:id="@+id/wvHH" android:layout_height="wrap_content" android:layout_width="100dip" android:layout_weight="1"/>
        <TextView android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="12sp" android:layout_marginTop="3dip" android:text="Hour" android:layout_width="fill_parent" android:gravity="center_horizontal" android:id="@+id/tvHH"></TextView>
    </LinearLayout>
    <LinearLayout android:layout_toLeftOf="@+id/wvMM" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical" android:id="@+id/llMM" android:layout_marginLeft="10dip">
        <kankan.wheel.widget.WheelView android:id="@+id/wvMM" android:layout_height="wrap_content" android:layout_width="50dip"/>
        <TextView android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="12sp" android:layout_marginTop="3dip" android:layout_width="fill_parent" android:gravity="center_horizontal" android:id="@+id/tvMM" android:text="Minutes"></TextView>
    </LinearLayout>
    <LinearLayout android:layout_toLeftOf="@+id/wvSS" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical" android:id="@+id/llSS" android:layout_marginLeft="10dip">
        <kankan.wheel.widget.WheelView android:id="@+id/wvSS" android:layout_height="wrap_content" android:layout_width="50dip"/>
        <TextView android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="12sp" android:layout_marginTop="3dip" android:layout_width="fill_parent" android:gravity="center_horizontal" android:id="@+id/tvSS" android:text="Seconds"></TextView>
    </LinearLayout>
    <LinearLayout android:layout_toLeftOf="@+id/wvMS" android:layout_height="wrap_content" android:layout_width="wrap_content" android:orientation="vertical" android:id="@+id/llMS" android:layout_marginLeft="10dip">
        <kankan.wheel.widget.WheelView android:id="@+id/wvMS" android:layout_height="wrap_content" android:layout_width="65dip"/>
        <TextView android:layout_height="wrap_content" android:textColor="#FFFFFF" android:textSize="12sp" android:layout_marginTop="3dip" android:layout_width="fill_parent" android:gravity="center_horizontal" android:id="@+id/tvMS" android:text="Milli Seconds"></TextView>
    </LinearLayout>
</LinearLayout>

</RelativeLayout>

I´m using the wheel code as a library project and I´m loading this layout 
inflating it in a new view and loading it inside a quick action.
I´m filling it´s values using a NumericWheelAdapter.
The behavior for me is: if I touch exactely on the gray frame it moves the 
wheel just a bit. As my finger gets away from the center it stops. If I double 
touch the center the number center again but I can´t scroll the wheel at all. 
It´s just a prety small move.

Original comment by gsim...@gmail.com on 19 Jan 2011 at 1:47

GoogleCodeExporter commented 8 years ago
Solved the problem for me!
(having a WheelView inside a ScrollView)

Thank you so much!

Original comment by xshadowm...@gmail.com on 19 Jan 2011 at 1:42

GoogleCodeExporter commented 8 years ago
Any ideas?

Original comment by gsim...@gmail.com on 21 Jan 2011 at 2:27

GoogleCodeExporter commented 8 years ago
I'm working on it, will comment soon

Original comment by yuri.kan...@gmail.com on 21 Jan 2011 at 9:02

GoogleCodeExporter commented 8 years ago
gsimoes,

Could you please provide sources (as less as possible) that reproduce your 
issue? I mean an activity code that works with this provided layout.

Provided layout works fine for me.

Original comment by yuri.kan...@gmail.com on 23 Jan 2011 at 7:11

GoogleCodeExporter commented 8 years ago
All I did was to add a NumericWheelAdapter to one of the wheels.
When I try to scrool it it seems to lose the touch just after my finger leaves 
the center of the wheel.
As I told you this layout is inflated to a view which is exhibited as a quick 
action. that´s just it. :(

Original comment by gsim...@gmail.com on 24 Jan 2011 at 4:19

GoogleCodeExporter commented 8 years ago
In this case it depends on your implementation of a quick action.
So, without code that reproduces this issue I'm unable to help you.

All that the wheel needs for scrolling is the touching event that depends on 
the parent behavior.

Original comment by yuri.kan...@gmail.com on 25 Jan 2011 at 1:38

GoogleCodeExporter commented 8 years ago
I will check it out again and see if I can find a way out. I´ve tried many 
native widgets and since they all work, I may find a fix for the problem.

Thanks,
Gabriel Simões

Original comment by gsim...@gmail.com on 25 Jan 2011 at 10:36

GoogleCodeExporter commented 8 years ago
Fixed in the latest version! thank you very much.

Original comment by gsim...@gmail.com on 30 Jan 2011 at 6:41

GoogleCodeExporter commented 8 years ago
Great :)

Original comment by yuri.kan...@gmail.com on 31 Jan 2011 at 7:43

GoogleCodeExporter commented 8 years ago
I'm experiencing this issue again, on Android 4.0 devices. The wheels refuse to 
move if in a ScrollView. Works fine on pre-4.0 devices. Anyone else having this 
problem?

Original comment by hohra...@gmail.com on 15 Mar 2012 at 11:20

GoogleCodeExporter commented 8 years ago
Im having the same problem, wheel stopped workng when my phone upgraded to 4.0

Original comment by rosa...@tradingmotion.com on 7 Jun 2012 at 11:14

GoogleCodeExporter commented 8 years ago
i have the same problem too: android 4.0

Original comment by zuzo...@gmail.com on 21 Jul 2012 at 3:37

GoogleCodeExporter commented 8 years ago
This is not fixed. I have the latest version of the Wheel but running on a real 
device (Samsung Galaxy SII) with Android 4.0.4 the Wheel scrolls inside a 
ScrollView but it is VERY unresponsive. I need to make sure to click precisely 
in the center of the wheel hold my position for a moment and slowly scroll. 
With the same wheel outside of the ScrollView it functions flawlessly.

My layout:

--------------main layout
LinearLayout
 ScrollView
  LinearLayout
-----------------compound control layout
   LinearLayout
    WheelView
    WheelView
    WheelView

Not sure if it matters but the direct parent of the wheel is not the ScrollView 
so the call to getParent().requestDisallowInterceptTouchEvent(true) might not 
be working properly. The WheelView is inside a compound control and I believe 
the parent LinearLayout is being merged into the next parent so the end result 
overall is only 2 LinearLayouts not 3 (I could be mistaken about that). 

I tried to put a while loop in its place that recursively went through all 
parent checking for ScrollViews and making the appropriate call as needed but 
this didn't work either.

Original comment by akuse...@gmail.com on 4 Feb 2013 at 6:28

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I found a solution to this. In WheelView.java on line 611 change the switch 
statement to the following:

switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN: //added to fix problem
    case MotionEvent.ACTION_MOVE:
        if (getParent() != null) {
            getParent().requestDisallowInterceptTouchEvent(true);
    }
    break;

    case MotionEvent.ACTION_UP:
        if (getParent() != null) { //added to fix problem, this may be uneeded
            getParent().requestDisallowInterceptTouchEvent(false);
        }

    if (!isScrollingPerformed) {
        int distance = (int) event.getY() - getHeight() / 2;
        if (distance > 0) {
            distance += getItemHeight() / 2;
        } else {
                distance -= getItemHeight() / 2;
        }
        int items = distance / getItemHeight();
        if (items != 0 && isValidItemIndex(currentItem + items)) {
                notifyClickListenersAboutClick(currentItem + items);
            }
    }
    break;
}

Original comment by akuse...@gmail.com on 4 Feb 2013 at 6:54