【问题标题】:How to move the popup window when the virtual kayboard is open in android?在android中打开虚拟键盘时如何移动弹出窗口?
【发布时间】:2014-07-17 15:21:05
【问题描述】:

我在 popup-window.am 中有 EditText 和 Button 在屏幕底部显示弹出窗口。当我尝试在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());

【问题讨论】:

  • 从弹出窗口更改为 DialogFragment 您将免费获得移动
  • @Blundell 如何在自定义位置显示对话框片段。
  • 你不能 :-) 因此评论而不回答

标签: android android-popupwindow


【解决方案1】:

尝试使用

android:windowSoftInputMode="adjustPan|adjustResize"

在活动清单文件中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-04
    相关资源
    最近更新 更多