JulianSymes JulianSymes - 1 year ago 72
Android Question

What is the definition of the value supplied by the Android function View.getHitRect()?

"Hit rectangle in parent's coordinates". But what does that mean?

To amplify, what I really want to know is the meaning of the phrase "hit rectangle". What is it for? How does the framework process it? When in the lifecycle is the return value meaningful? How might it differ from the rectangle defined by


Based on the name of the function I can of course guess at an answer, and try a few examples, but that's not satisfactory. I can find nothing useful about this function on the Android Developer website, or anywhere else I've looked.

Answer Source

Here appears to be the most complete explanation.

The getHitRect() method gets the child's hit rectangle (touchable area) in the parent's coordinates.

The example snippet uses the function to determine the current touchable area of a child view (after layout) in order to effectively extend it by creating a TouchDelegate

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download