16

I have a vertical LinearLayout. It shall act as a quick jump bar. So the width is very small and the height matches nearly the whole screen height. When I touch it and move around inside, everything is fine. That means, my onTouchEvent() is called and I can get (and follow) the position of the finger. But since the bar is not very wide, the user can easily drift outside of that view. So it would be necessary to let the user continue the movement even when outside the view. In fact the same thing like a ListView does.

I don't know why a ListView's onTouchEvent() is called even when outside the ListView, but not in case of my LinearLayout. I tracked it down back to the dispatchTouchEvent(). Here the situation is the same that method is always called for the ListView (even when outside) but not in case of the LinearLayout (when moving outside).

I'd be very happy if someone could give me a hint. Thanks a lot!

Bernd

Vasily Kabunov
  • 6,511
  • 13
  • 49
  • 53
Bernd
  • 675
  • 2
  • 8
  • 30
  • possible duplicate of [Is there an example of how to use a TouchDelegate in Android to increase the size of a view's click target?](http://stackoverflow.com/questions/1343222/is-there-an-example-of-how-to-use-a-touchdelegate-in-android-to-increase-the-siz) – David Snabel-Caunt Mar 12 '12 at 13:32

2 Answers2

8

You could use Android's TouchDelegate feature. It supports a bigger touch area for single views. Here is an example: https://stackoverflow.com/a/1343796/636579

Community
  • 1
  • 1
Tim
  • 6,692
  • 2
  • 25
  • 30
  • 3
    Yes I saw that post already, but as far as I understood it is only possible to extend it to the next parent's size. That would mean, in order to get the full screen height, the whole view tree must be evaluated. I was not able to figure out how ListView does this trick. – Bernd Mar 12 '12 at 13:45
7

i think that you should try increasing the padding of a view from all sides so that when user will click near the view in area of padding the ontouch or onClick method will be called

android:padding="10dp"
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
Mehroz Munir
  • 2,248
  • 1
  • 18
  • 16