Looking at the Drawable docs, we have a new method setHotspot (float x, float y)
with the description of:
Specifies the hotspot's location within the drawable.
With no other explanations on that page, I wonder what the purpose is.
Hotspots are used to pipe touch events into RippleDrawable, but can be used by custom drawables as well. If you are implementing a custom View that manages its own drawables, you will need to call setHotspot() from the drawableHotspotChanged() method for touch-centered ripples to work correctly.
From View.java:
@Override
public boolean onTouchEvent(MotionEvent event) {
...
case MotionEvent.ACTION_MOVE:
drawableHotspotChanged(x, y);
...
}
/**
* This function is called whenever the view hotspot changes and needs to
* be propagated to drawables managed by the view.
* <p>
* Be sure to call through to the superclass when overriding this function.
*
* @param x hotspot x coordinate
* @param y hotspot y coordinate
*/
public void drawableHotspotChanged(float x, float y) {
if (mBackground != null) {
mBackground.setHotspot(x, y);
}
}
From FrameLayout.java, which manages its own mForeground drawable:
@Override
public void drawableHotspotChanged(float x, float y) {
super.drawableHotspotChanged(x, y);
if (mForeground != null) {
mForeground.setHotspot(x, y);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With