处理在相对布局上的向下拖动
Handle dragging down on a relative layout
我有一个具有水平滚动图像查看器的相对布局。问题是这个相对布局的父视图也是一个 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>
我希望上面的 Relative 布局除了向下拖动手指并激活 Scroll 刷新之外,基本上可以传递所有其他手势。我需要该视图来处理水平滚动(它已经这样做了,但如果用户向下滚动一个小角度。它会稍微滑动图像查看器,但也会开始滑动以刷新。
我看过这个https://developer.android.com/training/gestures/viewgroup.html
但它让我感到困惑,我不确定它是否是我应该看的正确的东西?
有没有其他人必须处理水平滚动图像或任何滑动来刷新布局?
请帮忙:(
根据评论总结,RecyclerView 非常适合水平项目滚动问题。它比 ViewPager 更好,因为它支持回收项目。还有其他东西,比如动画。
为了防止SwipeRefreshLayout
对垂直移动触摸如此敏感,您可以使用such technique
我有一个具有水平滚动图像查看器的相对布局。问题是这个相对布局的父视图也是一个 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>
我希望上面的 Relative 布局除了向下拖动手指并激活 Scroll 刷新之外,基本上可以传递所有其他手势。我需要该视图来处理水平滚动(它已经这样做了,但如果用户向下滚动一个小角度。它会稍微滑动图像查看器,但也会开始滑动以刷新。
我看过这个https://developer.android.com/training/gestures/viewgroup.html 但它让我感到困惑,我不确定它是否是我应该看的正确的东西?
有没有其他人必须处理水平滚动图像或任何滑动来刷新布局?
请帮忙:(
根据评论总结,RecyclerView 非常适合水平项目滚动问题。它比 ViewPager 更好,因为它支持回收项目。还有其他东西,比如动画。
为了防止SwipeRefreshLayout
对垂直移动触摸如此敏感,您可以使用such technique