0

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.

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


Some of the codes

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

Notes:

  • 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
mr5
  • 3,438
  • 3
  • 40
  • 57

1 Answers1

0

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.

Community
  • 1
  • 1
mr5
  • 3,438
  • 3
  • 40
  • 57