bduncavage / PullToRefresharp

A pull-to-refresh library for Android in C#
38 stars 78 forks source link

Objects on scrollview intercept touch events, pull to refresh doesn't work in that case #1

Open gerryhigh opened 11 years ago

gerryhigh commented 11 years ago

I'm testing this out on a scenario where the scrollview has variable sized content and thus may not always scroll on its own. In that scenario if you have say an TextView with a click handler it is intercepting the touch event and the pull to refresh feature doesn't work.

Try this: <?xml version="1.0" encoding="utf-8"?> <pulltorefresharp.android.views.ViewWrapper xmlns:android="http://schemas.android.com/apk/res/android" xmlns:pullToRefresharpWrapper="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <pulltorefresharp.android.widget.ScrollView android:id="@+id/scrollview" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true" android:background="@color/content_background"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="2000dp" android:minWidth="25px" android:minHeight="25px">
<TextView android:text="This is some text" android:gravity="center_vertical" android:layout_width="fill_parent" android:layout_height="44dp" android:layout_marginLeft="0dp" android:textSize="22sp" android:id="@+id/textview" android:layout_gravity="center_vertical" /> </pulltorefresharp.android.widget.ScrollView> </pulltorefresharp.android.views.ViewWrapper>

And then in code, bind to the textview like so: var tv = view.FindViewById(Resource.Id.textview); tv.Click += (object sender, EventArgs e) => { Console.WriteLine("clicked on ..."); };

The PTR scrollview widget's OnTouchEvent never gets called. I'm going to do some more testing to see how to fix this but wanted to post it in case you've already tested this scenario.

Thanks.

bduncavage commented 11 years ago

Thanks for the report. The usage with ScrollView is the least tested. I will look into this issue, as I have an idea of what may be happening.