dismiss the keypad

Xml: 


    

    
rel1 = (RelativeLayout) findViewById(R.id.rel1);
rel1.setOnTouchListener(
                new View.OnTouchListener()
                {
                    @Override
                    public boolean onTouch(View view, MotionEvent ev) {
                        hideKeyboard(view);
                        return false;
                    }
                });
private void hideKeyboard(View v) {

        InputMethodManager inputMethodManager =(InputMethodManager)getSystemService(MainActivity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
    }