How can i hide ImageView
when keyboard appears (after pressing on some EditText
).
And then show this ImageView
when keyboard is dismissed?
Asked
Active
Viewed 3,607 times
8

Procurares
- 2,169
- 4
- 22
- 34
2 Answers
3
I think OnFocusChangeListener
might be the right thing for you.
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
// view/hide ImageView
}
});

poitroae
- 21,129
- 10
- 63
- 81
-
4It works fine. But i faced another problem. By pressing Back button, to hide keyboard, `EditText` don't loose focus, so ImageViw is still Hiden. Is there some listener for dismissing keyboard? – Procurares Mar 18 '13 at 21:10
-
@Procurares I'm glad you like it! Please upvote/accept the answer, if it helped you. Yep, that's possible. Read on that link to find out how: http://stackoverflow.com/questions/4312319/howto-capture-the-virtual-keyboard-show-hide-event-in-android – poitroae Mar 19 '13 at 16:46
3
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);
}
});

K_Anas
- 31,226
- 9
- 68
- 81