键盘出现时隐藏ImageView,键盘消失时显示

时间:2013-03-18 15:35:47

标签: android keyboard android-imageview android-edittext

键盘出现时如何隐藏ImageView(按下某些EditText后)。 然后在解除键盘时显示此ImageView

2 个答案:

答案 0 :(得分:3)

我认为OnFocusChangeListener对你来说可能是正确的。

editText.setOnFocusChangeListener(new OnFocusChangeListener() {

    @Override
    public void onFocusChange(View v, boolean hasFocus) {
        // view/hide ImageView
    }
});

答案 1 :(得分: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);
    }
});