How to lose the focus of a edittext when "done" button in the soft keyboard is pressed?

Call clearFocus method of EditText to lose focus when done button is clicked from soft-keyboard. do it as:

editText.setOnEditorActionListener(new OnEditorActionListener() {        
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if(actionId==EditorInfo.IME_ACTION_DONE){
            //Clear focus here from edittext
             editText.clearFocus();
        }
    return false;
    }
});

and also add android:imeOptions="actionDone" in edittext xml


If anyone comes across this question wondering how they could unfocus everything at once in their activity, they can set the focus on the parent layout (or any layout for that matter).

findViewById(R.id.myLayout).requestFocus();