Class Overview
Helper class to handle situations where you want a view to have a larger touch area than its
actual view bounds. The view whose touch area is changed is called the delegate view. This
class should be used by an ancestor of the delegate. To use a TouchDelegate, first create an
instance that specifies the bounds that should be mapped to the delegate and the delegate
view itself.
The ancestor should then forward all of its touch events received in its
onTouchEvent(MotionEvent)
to onTouchEvent(MotionEvent)
.
Summary
Constants |
int |
ABOVE |
The touchable region of the View extends above its actual extent. |
int |
BELOW |
The touchable region of the View extends below its actual extent. |
int |
TO_LEFT |
The touchable region of the View extends to the left of its
actual extent. |
int |
TO_RIGHT |
The touchable region of the View extends to the right of its
actual extent. |
Public Methods |
boolean
|
onTouchEvent(MotionEvent event)
Will forward touch events to the delegate view if the event is within the bounds
specified in the constructor.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
Constants
public
static
final
int
ABOVE
The touchable region of the View extends above its actual extent.
Constant Value:
1
(0x00000001)
public
static
final
int
BELOW
The touchable region of the View extends below its actual extent.
Constant Value:
2
(0x00000002)
public
static
final
int
TO_LEFT
The touchable region of the View extends to the left of its
actual extent.
Constant Value:
4
(0x00000004)
public
static
final
int
TO_RIGHT
The touchable region of the View extends to the right of its
actual extent.
Constant Value:
8
(0x00000008)
Public Constructors
public
TouchDelegate
(Rect bounds, View delegateView)
Parameters
bounds
| Bounds in local coordinates of the containing view that should be mapped to
the delegate view |
delegateView
| The view that should receive motion events
|
Public Methods
public
boolean
onTouchEvent
(MotionEvent event)
Will forward touch events to the delegate view if the event is within the bounds
specified in the constructor.
Parameters
event
| The touch event to forward |
Returns
- True if the event was forwarded to the delegate, false otherwise.