Code example for MotionEvent

Methods: getXgetY

0
    @Override 
    public boolean dispatchHoverEvent(MotionEvent event) {
        // Ignore hover events outside of this panel bounds since such events 
        // generate spurious accessibility events with the panel content when 
        // tapping outside of it, thus confusing the user. 
        final int x = (int) event.getX();
        final int y = (int) event.getY();
        if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
            return super.dispatchHoverEvent(event);
        } 
        return true; 
    } 
 
    public void setTrigger(View v) {
        mTrigger = v;
    } 
 
    public void openPanel() { 
        setVisibility(View.VISIBLE);
        if (mTrigger != null) mTrigger.setSelected(true);
        refresh();