2016-10-12 40 views
1

我有一個具有水平滾動圖像查看器的相對佈局。問題是這個相對佈局的父視圖也是一個SwipeToRefreshLayout,所以當用戶稍微向下滾動時,它會啓動ac。見代碼:處理拖動相對佈局

<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> 

我想上面的相對佈局基本上通過所有其他手勢,除了上下拖動手指,激活滾動刷新。我需要這個視圖來處理水平滾動(它已經做到了,但是如果用戶向下滾動一點角度,它會略微滑動圖像查看器,但也會開始刷新以進行刷新。)

我已經看過https://developer.android.com/training/gestures/viewgroup.html 但其令人難以置信我的腦海裏,我不知道,如果它甚至是對的,我的東西應該看什麼?

任何人都有處理水平滾動的圖像或任何在刷卡刷新佈局?

請幫助:(

+0

你有一些非常特殊的圖像滑塊?因爲它通常基於水平的「RecyclerView」,並沒有這樣的問題。 – Beloo

+0

我正在使用viewpager。我試圖現在實現Recyclerview,它仍然有相同的問題 – x10sion

+0

看看[this](http://stackoverflow.com/questions/23989910/horizo​​ntalscrollview-inside-swiperefreshlayout)和[this](http://stackoverflow.com/questions/34136178/swiperefreshlayout-blocking-horizo​​ntal-scrolled-recyclerview)問題 – Beloo

回答

2

作爲評論摘要,RecyclerView非常適合橫向項目滾動問題。它比ViewPager更好,因爲它支持回收項目。還有其他的東西,比如動畫。

爲了防止SwipeRefreshLayout是垂直運動的觸摸非常敏感,你可以使用such technique