1. <legend id='YWa0K'><style id='YWa0K'><dir id='YWa0K'><q id='YWa0K'></q></dir></style></legend>
      <bdo id='YWa0K'></bdo><ul id='YWa0K'></ul>
    1. <small id='YWa0K'></small><noframes id='YWa0K'>

      <tfoot id='YWa0K'></tfoot>

      <i id='YWa0K'><tr id='YWa0K'><dt id='YWa0K'><q id='YWa0K'><span id='YWa0K'><b id='YWa0K'><form id='YWa0K'><ins id='YWa0K'></ins><ul id='YWa0K'></ul><sub id='YWa0K'></sub></form><legend id='YWa0K'></legend><bdo id='YWa0K'><pre id='YWa0K'><center id='YWa0K'></center></pre></bdo></b><th id='YWa0K'></th></span></q></dt></tr></i><div id='YWa0K'><tfoot id='YWa0K'></tfoot><dl id='YWa0K'><fieldset id='YWa0K'></fieldset></dl></div>

      如何居中弹出窗口?

      时间:2024-04-14

            <i id='LEmT8'><tr id='LEmT8'><dt id='LEmT8'><q id='LEmT8'><span id='LEmT8'><b id='LEmT8'><form id='LEmT8'><ins id='LEmT8'></ins><ul id='LEmT8'></ul><sub id='LEmT8'></sub></form><legend id='LEmT8'></legend><bdo id='LEmT8'><pre id='LEmT8'><center id='LEmT8'></center></pre></bdo></b><th id='LEmT8'></th></span></q></dt></tr></i><div id='LEmT8'><tfoot id='LEmT8'></tfoot><dl id='LEmT8'><fieldset id='LEmT8'></fieldset></dl></div>

            <small id='LEmT8'></small><noframes id='LEmT8'>

              • <bdo id='LEmT8'></bdo><ul id='LEmT8'></ul>
                <legend id='LEmT8'><style id='LEmT8'><dir id='LEmT8'><q id='LEmT8'></q></dir></style></legend>
                  <tbody id='LEmT8'></tbody>
                <tfoot id='LEmT8'></tfoot>
              • 本文介绍了如何居中弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                I created an Activity in which i add a button that throws a popup when is clicked. Here is the code of showPopup() method:

                    private void showPopup() {
                    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                
                    View layout = inflater.inflate(R.layout.popup_layout, (ViewGroup) findViewById(R.id.popup_element), false);
                
                    final PopupWindow pwindo = new PopupWindow(layout, LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, true);
                
                    Button btnAgree = (Button) layout.findViewById(R.id.ok);
                    btnAgree.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            pwindo.dismiss();
                        }
                    });
                
                    pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);
                    }
                }
                

                I would center it both vertically and orizzontally. I tried several ways that i see here on SO but none worked. Why i always get the popup window at the top of the screen?

                解决方案

                you can use setHorizontalOffset:

                ListPopupWindow popupWindow = new ListPopupWindow(this);
                
                // Position
                popupWindow.setAnchorView(btn);
                popupWindow.setPromptPosition (ListPopupWindow.POSITION_PROMPT_ABOVE);
                popupWindow.setHorizontalOffset((btn.layoutParams.width - popupWindow.getWidth())/2);
                

                这篇关于如何居中弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:GCM IntentService 如何在收到通知时显示弹出窗口 下一篇:如何更改微调器弹出窗口的背景颜色?

                相关文章

                    <bdo id='1GYrf'></bdo><ul id='1GYrf'></ul>
                1. <legend id='1GYrf'><style id='1GYrf'><dir id='1GYrf'><q id='1GYrf'></q></dir></style></legend>
                  <i id='1GYrf'><tr id='1GYrf'><dt id='1GYrf'><q id='1GYrf'><span id='1GYrf'><b id='1GYrf'><form id='1GYrf'><ins id='1GYrf'></ins><ul id='1GYrf'></ul><sub id='1GYrf'></sub></form><legend id='1GYrf'></legend><bdo id='1GYrf'><pre id='1GYrf'><center id='1GYrf'></center></pre></bdo></b><th id='1GYrf'></th></span></q></dt></tr></i><div id='1GYrf'><tfoot id='1GYrf'></tfoot><dl id='1GYrf'><fieldset id='1GYrf'></fieldset></dl></div>

                  1. <tfoot id='1GYrf'></tfoot>

                    <small id='1GYrf'></small><noframes id='1GYrf'>