android - throw 后触摸被拦截

标签 android touch-event nestedscrollview

最近我的 ScrollView 遇到了一些问题。发生滑动后,触摸事件不会到达 ScrollView 内的元素。发生闪动后,我首先需要再次点击 View ,然后恢复正常行为。我已经尝试了很多解决方法,例如:

  • 在 throw 后手动触发运动事件(向上/向下)。这可行,但有一些严重的问题,我不必解释我猜的原因,因为这与再次触摸 View 相同,但在某个 x+y 点。
  • 拦截触摸事件并始终将它们传递给底层 View 。

但这一切都非常麻烦,而且这看起来首先是不受欢迎的行为,不是吗?

似乎 ScrollView 在 onfling 发生后拦截所有内容,直到出现新的正常(无滑动)上下触摸。

 <android.support.v4.widget.NestedScrollView
    android:id="@+id/fsv_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@color/white">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/marker"
        android:padding="@dimen/spacing_small"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_jobs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />

</LinearLayout>

</android.support.v4.widget.NestedScrollView>

最佳答案

您有一个 ScrollView (NestedScrollView),其中包含另一个 ScrollView (RecyclerView)。 对我来说听起来很麻烦。

为什么需要这样的布局?

关于android - throw 后触摸被拦截,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33414912/

相关文章:

c# - 在 Xamarin.Android 中隐藏标题栏

java - Retrofit 2 返回 HTML 而不是 JSON

android - 如何在登录成功后开始另一个 Activity

ios - uitextview 成为第一响应者后,UIButton 不调度触摸事件

android - NestedScrollView 和 RecyclerView 问题,如何分离?

java - 自定义硬件按钮事件/Intent

android - ListView 中的自定义 onInterceptTouchEvent

ios - 将触摸事件传递给 UICollectionViewCell 内容?

android - 防止 NestedScrollView 自动滚动到顶部

Android NestedScrollView 在 ListView 中仅显示一项