1

I have a relative layout that has a horizontal scrolling image viewer. The issue is that the parent view of this relative layout is also a SwipeToRefreshLayout so when the user scrolls down slightly it starts ac. See code:

    <android.support.v4.widget.SwipeRefreshLayout
      android:id="@+id/item_activity_swipe_refresh_layout"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".item.ItemActivity">



      <android.support.design.widget.CoordinatorLayout
        android:id="@+id/item_activity_coordinatorLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.design.widget.AppBarLayout
          android:id="@+id/item_activity_app_bar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:fitsSystemWindows="true"
          app:elevation="0dp"
          app:theme="@style/ToolbarStyle">

          <!--  This is the view I dont want to handle Swipe to refresh/Scroll content up (Scrolling down the screen) -->
            <RelativeLayout
                android:id="@+id/scrollable_image_container"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>


                <!--    ....omit other code -->
        </android.support.design.widget.AppBarLayout>
      </android.support.design.widget.CoordinatorLayout>  
    </android.support.v4.widget.SwipeRefreshLayout>

I want the above Relative layout to basically pass all other gestures besides dragging your finger down and activating the Scroll to refresh. I need that view to handle horizontal scrolling (which it does already but if the user scrolls at a slight angle downwards. It slides the image viewers slightly but also starts the swipe to refresh.

i've had a look at this https://developer.android.com/training/gestures/viewgroup.html but its boggling my mind and am not sure if its even the right thing i should be looking at?

Has anyone else had to handle horizontal scrolling images or anything in a swipe to refresh layout?

Please help :(

Stillie
  • 2,647
  • 6
  • 28
  • 50
  • Do you have some very special image slider? Because it typically base on horizontal `RecyclerView` and it doesn't have such problems. – Beloo Oct 12 '16 at 07:21
  • I am using a viewpager. I tried to implement Recyclerview now and it still has the same issue – Stillie Oct 12 '16 at 08:07
  • Look at [this](http://stackoverflow.com/questions/23989910/horizontalscrollview-inside-swiperefreshlayout) and [this](http://stackoverflow.com/questions/34136178/swiperefreshlayout-blocking-horizontally-scrolled-recyclerview) questions – Beloo Oct 12 '16 at 08:14
  • Thank you!!! http://stackoverflow.com/a/23989911/4578531 this one fixed it for me! If you want you can set that as your answer and i will accept it! Thank you so much! – Stillie Oct 12 '16 at 08:39

1 Answers1

2

As summary from comments, RecyclerView is great for horizontal items scrolling issues. It is better, than ViewPager, because it supports recycling items. And other stuff, like animations.

To prevent SwipeRefreshLayout being so sensitive to vertical movement touches, you may use such technique

Community
  • 1
  • 1
Beloo
  • 9,723
  • 7
  • 40
  • 71