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>

      如何居中弹出窗口?

      How to center PopupWindow?(如何居中弹出窗口?)

            <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);
                

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

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Sqlite database not copied from asset folder Android(Sqlite 数据库未从资产文件夹 Android 复制)
                SQLite Database Copy Appears Corrupted When Generated by Device and not Emulator(SQLite 数据库副本在由设备而不是模拟器生成时出现损坏)
                Android file copy(安卓文件拷贝)
                Android how to detect Copy event of Edittext in android(Android如何在android中检测Edittext的Copy事件)
                Android copy image from gallery folder onto SD Card alternative folder(Android将图像从图库文件夹复制到SD卡替代文件夹)
                Is there a tool to find unused resources in an Android project?(是否有工具可以在 Android 项目中查找未使用的资源?)
                    <bdo id='1GYrf'></bdo><ul id='1GYrf'></ul>
                    • <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>
                          <tbody id='1GYrf'></tbody>

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