Hide ImageView when the keyboard appears and show it when the keyboard disappears

How can I hide ImageViewwhen the keyboard appears (after clicking on EditText). And then show it ImageViewwhen the keyboard deviates?

+5
source share
2 answers

I think that OnFocusChangeListenermay be right for you.

editText.setOnFocusChangeListener(new OnFocusChangeListener() {

    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        // view/hide ImageView
    }
});
+1
source
edit_Text.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
    if(hasFocus){
        Toast.makeText(getApplicationContext(), "got the focus", Toast.LENGTH_LONG).show();
             // Hide your ImageView
               iv.setVisibility(View.GONE);  // (make the view gone)
    }else
        Toast.makeText(getApplicationContext(), "lost the focus", Toast.LENGTH_LONG).show();
            // Show your ImageView
              iv.setVisibility(View.VISIBLE);
    }
});
+1
source

All Articles