接收触摸事件滚动时prevent的ImageView [英] Prevent ImageView from receiving touch events when scrolling

查看:152
本文介绍了接收触摸事件滚动时prevent的ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与许多的ImageView 所组成的应用程序,我需要在他们中的一些附加一个触摸监听器。虽然这样做,我遇到了一个问题。如果指针在其中的ImageView 与连接到它的触摸听众和即将产生一个滚动事件,似乎在<$ C之间的战斗场景中的位置,按住$ C>查看 S和滚动型在W / C该事件实际上发生在W / C的事件应该属于。在以很快的速度在屏幕滚动,然后返回其中第一个指针被感动了,所以这意味着它是一种不必要的行为。

I'm making an app with lots of ImageViews and I needed to attach a touch listener in some of them. While doing this, I encountered a problem. If the pointer was held down at the location where the ImageView with touch listeners attached to it and was about to produce a scrolling event, there seems a fighting scene between the Views and the ScrollView in w/c where the event was actually occured and in w/c the event is supposed to belong. The screen scrolls in a fast rate then return where the first pointer was touched down, so it means it is an unwanted behavior.

设置一个 onTouchListener 的ImageView 使得滚动不安和不必要的,我怎么prevent 的ImageView 接收触摸事件时滚动?

Setting an onTouchListener in the ImageView makes the scrolling uneasy and unwanted, how do I prevent ImageView from receiving touch events when scrolling?

布局 act_map_view.xml

<?xml version="1.0" encoding="utf-8"?>

<com.nkraft.mobiletomblocator.CustomVScroll
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/vScroll"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none" >

    <com.nkraft.mobiletomblocator.CustomHScroll 
        android:id="@+id/hScroll"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scrollbars="none" >

            <com.nkraft.mobiletomblocator.CustomGridLayout
                android:id="@+id/map_grid"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            </com.nkraft.mobiletomblocator.CustomGridLayout>

    </com.nkraft.mobiletomblocator.CustomHScroll>

</com.nkraft.mobiletomblocator.CustomVScroll>

注:


  • 网​​格布局在运行时填充的ImageView 秒。

  • 我定制了自己的水平和垂直滚动型,这样我可以在两个方向上同时滚动即角滚动

  • The GridLayout is populated with ImageViews at runtime.
  • I customized my horizontal and vertical ScrollView so that I can scroll in both directions concurrently i.e diagonal scrolling

推荐答案

从我提到的注意事项,我想从我目前所面临的问题的线索。我认为这是实现标准Android的滚动条前,这一问题一直被认为。发生这种情况对我来说,主要的原因是我扩展的类滚动条,完全取代它的默认行为。所以对我来说,以达到我想要的(对角滚动滚动条)我遵循这个<一个href=\"http://web.archive.org/web/20131020193237/http://blog.gorges.us/2010/06/android-two-dimensional-scrollview\"相对=nofollow>帖子并更换我的两个垂直和水平滚动视图本 TwoDScrollView ,也感谢这个<一个href=\"http://stackoverflow.com/questions/2044775/scrollview-vertical-and-horizontal-in-android#answer-5224088\">post指导我给它。

From the notes I've mention, I figured a clue from the problem I'm currently facing. I think this issue had been thought before the standard android's scrollbar was implemented. The main reason this occurs to me is that I extended the class of the scrollbars and totally replacing the default behavior of it. So for me to achieve what I want (the scrollbar with diagonal scrolling) I follow this post and replace both my vertical and horizontal scrollview with this TwoDScrollView, also thanks for this post directing me to it.

这篇关于接收触摸事件滚动时prevent的ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆