提问者:小点点

控制相对布局上的向下拖动


我有一个相对布局,有一个水平滚动图像查看器。问题是此相对布局的父视图也是滑动刷新布局,因此当用户稍微向下滚动时,它会启动 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/view group . html,但它让我感到困惑,我不确定它是否是我应该看的东西?

有没有其他人必须处理水平滚动图像或滑动中的任何东西来刷新布局?

请帮助:(


共1个答案

匿名用户

根据评论总结,RecyclerView非常适合水平项目滚动问题。它比ViewPager更好,因为它支持回收项目。还有其他东西,比如动画。

为了防止滑动刷新布局对垂直移动触摸如此敏感,您可以使用这种技术