zoukankan      html  css  js  c++  java
  • android popupwindow

    通过LayoutInflater得到一个View,在设定一个宽高,放入到PopupWindow类中即可。

    关键的代码:

    ----------------------------------------------------------------------------

    初始化:

            View v = LayoutInflater.from(this).inflate(R.layout.popup, null);         //PopupWindow 的自定义View
            v.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);  //根据内容大小自定义高宽

        PopupWindow popupWindow = new PopupWindow(v, v.getMeasuredWidth(), v.getMeasuredHeight());     //通过构造函数初始化PopupWindow对象
            popupWindow.setFocusable(true);                                            //如果想设置点击window外部,PopupWindow消失的话, 必须得加上这句话
            popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg));
            popupWindow.setOutsideTouchable(true); // 触摸popupwindow外部,popupwindow消失。这个要求你的popupwindow要有背景图片才可以成功,如上

    ----------------------------------------------------------------------------

       popupWindow.showAsDropDown(btnShowPopup);      //设置按哪个控件 会触发PopupWindow

           popupWindow.dismiss();                                          //PopupWindow 消失

    //        //PopupWindow 遮挡住软键盘解决方法
    //        historyPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    //        historyPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

  • 相关阅读:
    sql 数据库还原脚本 (kill链接+独占
    最长回文字符串
    UVa 455 Periodic Strings
    UVa 1225 Digit Counting
    UVa 340 Master-Mind Hints
    UVa 10976
    UVa 725
    UVa 11059
    POJ1887 最长下降子序列
    最大连续子序列算法(数组的连续子数组最大和(首尾不相连))
  • 原文地址:https://www.cnblogs.com/lianghui66/p/3090215.html
Copyright © 2011-2022 走看看