如何在android中打开虚拟键盘时移动弹出窗口?

时间:2014-07-17 07:09:56

标签: android android-popupwindow

我在popup-window.am中显示EditTextButton,在屏幕底部显示弹出窗口。当我尝试在EditText中输入详细信息时,弹出窗口隐藏在软键盘后面,无法看到EditText并且无法解决问题。任何人都知道帮我解决这个问题。

弹出窗口代码

search_popup_inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
search_popup_view = search_popup_inflater.inflate(R.layout.search_popup, null, true);
search_popup = new PopupWindow(search_popup_view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,true);

search = (EditText) search_popup_view.findViewById(R.id.search);
btn_search_enter = (Button) search_popup_view.findViewById(R.id.btn_search);

按钮后单击“显示弹出窗口”

search_popup.setBackgroundDrawable(new BitmapDrawable());

        search_popup.setTouchInterceptor(new OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {

                    search_popup.dismiss();

                    return true;
                }
                return false;
            }
        });

        //search_popup.showAtLocation(findViewById(R.id.line_lay), Gravity.TOP, locateView(view).left, locateView(view).bottom);
        search_popup.showAtLocation(findViewById(R.id.line_lay), Gravity.BOTTOM, 0, v.getHeight());

1 个答案:

答案 0 :(得分:1)

尝试使用

android:windowSoftInputMode="adjustPan|adjustResize"

在活动清单文件中。