Hide ImageView when keyboard appears, and show it when keyboard disappear

How can i hide ImageView when keyboard appears (after pressing on some EditText ). And then show this ImageView when keyboard is dismissed?


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

editText.setOnFocusChangeListener(new OnFocusChangeListener() {

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

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);
    }
});
链接地址: http://www.djcxy.com/p/70078.html

上一篇: 如何将UIScrollView的背景图像设置为可伸缩图像?

下一篇: 键盘出现时隐藏ImageView,并在键盘消失时显示