微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.widget.PopupWindow的实例源码

项目:boohee_v5.6    文件PopupWindowCompatGingerbread.java   
static int getwindowLayoutType(PopupWindow popupWindow) {
    if (!sGetwindowLayoutTypeMethodAttempted) {
        try {
            sGetwindowLayoutTypeMethod = PopupWindow.class.getDeclaredMethod("getwindowLayoutType",new Class[0]);
            sGetwindowLayoutTypeMethod.setAccessible(true);
        } catch (Exception e) {
        }
        sGetwindowLayoutTypeMethodAttempted = true;
    }
    if (sGetwindowLayoutTypeMethod != null) {
        try {
            return ((Integer) sGetwindowLayoutTypeMethod.invoke(popupWindow,new Object[0])).intValue();
        } catch (Exception e2) {
        }
    }
    return 0;
}
项目:GitHub    文件ReadEPubActivity.java   
private void initTocList() {
    mToclistadapter = new Toclistadapter(this,mChapterList,"",1);
    mToclistadapter.setEpub(true);
    mTocListPopupWindow = new ListPopupWindow(this);
    mTocListPopupWindow.setAdapter(mToclistadapter);
    mTocListPopupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    mTocListPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    mTocListPopupWindow.setAnchorView(mCommonToolbar);
    mTocListPopupWindow.setonItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent,View view,int position,long id) {
            mTocListPopupWindow.dismiss();
            currentChapter = position + 1;
            mToclistadapter.setCurrentChapter(currentChapter);
            viewpager.setCurrentItem(position);
        }
    });
    mTocListPopupWindow.setondismissListener(new PopupWindow.OndismissListener() {
        @Override
        public void ondismiss() {
            toolbaranimateHide();
        }
    });
}
项目:QMUI_Android    文件QMUIBasePopup.java   
/**
 * Constructor.
 *
 * @param context Context
 */
public QMUIBasePopup(Context context) {
    mContext = context;
    mWindow = new PopupWindow(context);
    mWindow.setTouchInterceptor(new OnTouchListener() {
        @Override
        public boolean onTouch(View v,MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                mWindow.dismiss();
                return false;
            }
            return false;
        }
    });

    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

}
项目:AdvancedTextView    文件SelectableTextView.java   
/**
 * 长按弹出菜单
 *
 * @param offsetY
 * @param actionMenu
 * @return 菜单创建成功,返回true
 */
private void showActionMenu(int offsetY,ActionMenu actionMenu) {

    mActionMenuPopupWindow = new PopupWindow(actionMenu,WindowManager.LayoutParams.WRAP_CONTENT,mActionMenuHeight,true);
    mActionMenuPopupWindow.setFocusable(true);
    mActionMenuPopupWindow.setoutsidetouchable(false);
    mActionMenuPopupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));
    mActionMenuPopupWindow.showAtLocation(this,Gravity.TOP | Gravity.CENTER_HORIZONTAL,offsetY);

    mActionMenuPopupWindow.setondismissListener(new PopupWindow.OndismissListener() {
        @Override
        public void ondismiss() {
            Selection.removeSelection(getEditableText());
            // 如果设置了分散对齐,ActionMenu销毁后,强制刷新一次,防止出现文字背景未消失的情况
            if (isTextJustify)
                SelectableTextView.this.postInvalidate();
        }
    });
}
项目:Tribe    文件LifeDetailActivity.java   
private void showPopUpWindow(View view) {
    WindowManager systemService = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE);
    int width = systemService.getDefaultdisplay().getWidth();
    int height = systemService.getDefaultdisplay().getHeight();
    int popWidth = (int) (width * 0.75);
    int popHeight = (int) (height * 0.64);
    PopupWindow popupWindow = new PopupWindow(this);
    popupWindow.setWidth(popWidth);
    popupWindow.setHeight(popHeight);
    View inflate = LayoutInflater.from(this).inflate(R.layout.ll_life_detail_pop,null);
    popupWindow.setContentView(inflate);
    popupWindow.setClippingEnabled(false);//设置覆盖状态栏,重点
    popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.rl_pop_top_corner));
    popupWindow.setoutsidetouchable(false);
    popupWindow.setFocusable(true);
    popupWindow.showAtLocation(view,Gravity.CENTER,0);

    initPopUpView(inflate);

}
项目:GitHub    文件CustomPopWindow.java   
/**
 * 添加一些属性设置
 * @param popupWindow
 */
private void apply(PopupWindow popupWindow){
    popupWindow.setClippingEnabled(mClippEnable);
    if(mIgnoreCheekPress){
        popupWindow.setIgnoreCheekPress();
    }
    if(mInputMode!=-1){
        popupWindow.setInputMethodMode(mInputMode);
    }
    if(mSoftInputMode!=-1){
        popupWindow.setSoftInputMode(mSoftInputMode);
    }
    if(mOndismissListener!=null){
        popupWindow.setondismissListener(mOndismissListener);
    }
    if(mOnTouchListener!=null){
        popupWindow.setTouchInterceptor(mOnTouchListener);
    }
    popupWindow.setTouchable(mTouchable);



}
项目:GongXianSheng    文件ProductTypePopup.java   
private void init(){
        View view = LayoutInflater.from(context).inflate(R.layout.popup_tab_type,null);
        setContentView(view);
        setSoftInputMode(PopupWindow.INPUT_METHOD_NEEDED);
        setBackgroundDrawable(new ColorDrawable(0x66000000));
        setSoftInputMode(WindowManager.LayoutParams.soFT_INPUT_ADJUST_RESIZE);
        setFocusable(false);
        setoutsidetouchable(false);
        mLayoutContainer = (ViewGroup)view.findViewById(R.id.layout_tab_container);

        view.setonClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });

//        setondismissListener(new PopupWindow.OndismissListener() {
//            @Override
//            public void ondismiss() {
//                ivOpen.setimageResource(R.drawable.arrow);
//            }
//        });
    }
项目:lqrwechatrongcloud    文件PopupWindowUtils.java   
/**
 * 得到一个自动识别在目标控件上方或下方的pupupwindow并显示
 *
 * @param contentView popupwindow要显示的视图
 * @param width       popupwindow的宽度
 * @param activity    能得到getwindowManager()的上下文
 * @return
 */
public static PopupWindow getPopupWindowAsDropDownParentAuto(View contentView,int width,int height,View anchorView,Activity activity) {

    //        View itemView = (View) contentView.getParent();// 得到contentView的父控件
    PopupWindow popupWindow = getPopupWindow(contentView,width,height);

    // 控制它放置的位置
    if (isShowBottom(activity,anchorView)) {// 显示popupwindow在itemView的下方,偏移量都为0
        popupWindow.showAsDropDown(anchorView,0);
    } else {// 显示popupwindow在itemView的上方,偏移量y都为-2*itemView.getHeight()
        popupWindow.showAsDropDown(anchorView,-2 * anchorView.getHeight());
    }

    return popupWindow;
}
项目:CCDownload    文件PopMenu.java   
public PopMenu(Context context,int resid,int checkedPosition,int height) {
        this.context = context;
        this.checkedPosition = checkedPosition;

        itemList = new ArrayList<String>();
        RelativeLayout view = new RelativeLayout(context);
//      view.setBackgroundResource(resid);

        listView = new ListView(context);
        listView.setPadding(0,ParamsUtil.dpToPx(context,3),3));
        view.addView(listView,new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        listView.setAdapter(new PopAdapter());
        listView.setonItemClickListener(this);

        popupWindow = new PopupWindow(view,context.getResources().getDimensionPixelSize(R.dimen.popmenu_width),height);
        popupWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(178,0)));
    }
项目:MyRepository    文件ScanImagesActivity.java   
/**
 * 初始化显示文件夹信息的popupWindow
 */
private void initPopupWindow() {
    popRecyclerview = new RecyclerView(this);
    popRecyclerview.setBackgroundColor(getResources().getColor(android.R.color.white));
    linearlayoutmanager layoutManager = new linearlayoutmanager
            (this,linearlayoutmanager.VERTICAL,false);
    popRecyclerview.setLayoutManager(layoutManager);
    popRecyclerview.addItemdecoration(new DividerItemdecoration(this,DividerItemdecoration.VERTICAL_LIST));
    popRecyclerview.setPadding(0,Commonutil.dp2px(this,5),0);

    int screenHeight = getResources().getdisplayMetrics().heightPixels;

    popupWindow = new PopupWindow(popRecyclerview,ViewGroup.LayoutParams.MATCH_PARENT,(int) (screenHeight * 0.6f));

    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setFocusable(true);
    popupWindow.setoutsidetouchable(false);
    popupWindow.setAnimationStyle(R.style.popup_anim);

    popupWindow.setondismissListener(new PopupWindow.OndismissListener() {
        @Override
        public void ondismiss() {
            fab.setVisibility(View.VISIBLE);
            WindowManager.LayoutParams attributes =
                    ScanImagesActivity.this.getwindow().getAttributes();
            attributes.alpha = 1;
            ScanImagesActivity.this.getwindow().setAttributes(attributes);
        }
    });

}
项目:yyox    文件ListFilePopWindow.java   
public ListFilePopWindow(Context context,View targetView) {
    super();
    this.targetView = targetView;
    View contentView = LayoutInflater.from(context).inflate(R.layout.kf5_list_file_dir,null);
    listView = (ListView) contentView.findViewById(R.id.kf5_list_dir);
    Point point = ScreenUtils.getScreenSize(context);
    int height = (int) (point.y * (4.5f / 8.0f));
    popupWindow = new PopupWindow();
    popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
    popupWindow.setHeight(height);
    popupWindow.setBackgroundDrawable(new BitmapDrawable());
    popupWindow.setoutsidetouchable(true);
    popupWindow.setFocusable(true);
    popupWindow.setTouchable(true);
    popupWindow.setondismissListener(new PopupWindow.OndismissListener() {

        @Override
        public void ondismiss() {
            // Todo Auto-generated method stub
            popupWindow.dismiss();
        }
    });
    popupWindow.setAnimationStyle(R.style.KF5FileListPopAnim);
    popupWindow.setContentView(contentView);
    listView.setonItemClickListener(this);
}
项目:QMUI_Android    文件QMUIBasePopup.java   
/**
 * Set content view.
 *
 * @param root Root view
 */
public void setContentView(View root) {
    if (root == null)
        throw new IllegalStateException("setContentView was not called with a view to display.");
    mRootViewWrapper = new RootView(mContext);
    mRootViewWrapper.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT));
    mRootView = root;
    mRootViewWrapper.addView(root);
    mWindow.setContentView(mRootViewWrapper);
    mWindow.setondismissListener(new PopupWindow.OndismissListener() {
        @Override
        public void ondismiss() {
            QMUIBasePopup.this.ondismiss();
            if (mdismissListener != null) {
                mdismissListener.ondismiss();
            }
        }
    });
}
项目:AssistantBySDK    文件ChooseSetPopupWindow.java   
private void initView() {
    View contentView = LayoutInflater.from(mContext).inflate(R.layout.popup_choose_set,null);
    contentView.findViewById(R.id.ll_shade).setonClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    mChooseWindow = new PopupWindow(contentView,-1,-1);
    //点击空白处的时候PopupWindow会消失
    mChooseWindow.setFocusable(true);
    mChooseWindow.setTouchable(true);
    mChooseWindow.setoutsidetouchable(true);
    mChooseWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    // mChooseWindow.setAnimationStyle(R.style.popupAnim);

    //初始化集数列表
    RecyclerView rvChooseSet = (RecyclerView) contentView.findViewById(R.id.rv_choose_set);
    rvChooseSet.setHasFixedSize(true);
    rvChooseSet.setLayoutManager(new GridLayoutManager(mContext,4));
    rvChooseSet.setAdapter(new ChooseSetAdapter());
}
项目:letv    文件AlbumHalfCommentController.java   
public void showPopupWindow(View target) {
    if (target != null) {
        if (this.morePopupWindow == null) {
            this.morePopupWindow = new PopupWindow(this.context);
            this.morePopupWindow.setBackgroundDrawable(new BitmapDrawable());
            this.morePopupWindow.setWidth(UIsUtils.zoomWidth(60));
            this.morePopupWindow.setHeight(UIsUtils.zoomWidth(40));
            this.morePopupWindow.setoutsidetouchable(true);
            this.morePopupWindow.setFocusable(true);
            this.morePopupWindow.setContentView(this.popupContentView);
        }
        int[] location = new int[2];
        target.getLocationOnScreen(location);
        LogInfo.log("Emerson","-----------location[1] = " + location[1]);
        LogInfo.log("fornia","location[0]:" + location[0] + "  location[1]:" + location[1]);
        this.morePopupWindow.showAtLocation(target,location[0] + ((target.getWidth() - UIsUtils.dipToPx(40.0f)) / 2),(location[1] + (target.getHeight() / 2)) - UIsUtils.dipToPx(60.0f));
        this.morePopupWindow.update();
    }
}
项目:TextReader    文件ReadEPubActivity.java   
private void initTocList() {
    mToclistadapter = new Toclistadapter(this,long id) {
            mTocListPopupWindow.dismiss();
            currentChapter = position + 1;
            mToclistadapter.setCurrentChapter(currentChapter);
            viewpager.setCurrentItem(position);
        }
    });
    mTocListPopupWindow.setondismissListener(new PopupWindow.OndismissListener() {
        @Override
        public void ondismiss() {
            toolbaranimateHide();
        }
    });
}
项目:Renrentou    文件CitySelectFragment.java   
private void initPopUp(){
    popupView = getActivity().getLayoutInflater().inflate(R.layout.popupwindow_city_select,null);
    mPopupWindow = new PopupWindow(popupView,LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT,true);
    mPopupWindow.setTouchable(true);
    mPopupWindow.setoutsidetouchable(true);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(),(Bitmap) null));
    popupView.findViewById(R.id.select_confirm).setonClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            provinceTv.setText(currentProvince.getAreaName());
            cityTv.setText(currentCity.getAreaName());
            countyTv.setText(currentCounty.getAreaName());
            mPopupWindow.dismiss();
        }
    });
}
项目:Simpler    文件WebViewActivity.java   
/**
 * 显示PopupWindow:WebView操作
 *
 * @param view
 */
private void showWebViewOpWindow(View view) {
    View contentView = getLayoutInflater().inflate(R.layout.window_webview_op,null);
    // 设置Item的点击事件
    LinearLayout llRefresh = (LinearLayout) contentView.findViewById(R.id.llRefresh);
    LinearLayout llcopyUrl = (LinearLayout) contentView.findViewById(R.id.llcopyUrl);
    LinearLayout llOpen = (LinearLayout) contentView.findViewById(R.id.llOpen);

    final PopupWindow popupWindow = new PopupWindow(contentView,RelativeLayout.LayoutParams.WRAP_CONTENT,true);

    OpClickListener listener = new OpClickListener(popupWindow);
    llRefresh.setonClickListener(listener);
    llcopyUrl.setonClickListener(listener);
    llOpen.setonClickListener(listener);

    // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
    popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.popup_transparent_bg));

    // 设置好参数之后再show
    popupWindow.showAsDropDown(view);
}
项目:PopupWindow    文件PopupActivity.java   
@Override
public void onClick(View v) {
    PopupWindow win=window.getPopupWindow();
    switch (v.getId()) {
        case R.id.translate_bt:
            win.setAnimationStyle(R.style.animTranslate);
            break;
        case R.id.alpha_bt:
            win.setAnimationStyle(R.style.animAlpha);
            break;
        case R.id.scale_bt:
            win.setAnimationStyle(R.style.animscale);
            break;
        case R.id.rotate_bt:
            win.setAnimationStyle(R.style.animRotate);
            break;
        default:break;
    }
    window.showAtLocation(activityPopup,Gravity.BottOM,0);
    WindowManager.LayoutParams lp=getwindow().getAttributes();
    lp.alpha=0.3f;
    getwindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    getwindow().setAttributes(lp);
}
项目:QMUI_Android    文件QDPopupFragment.java   
private void initnormalPopupIfNeed() {
    if (mnormalPopup == null) {
        mnormalPopup = new QMUIPopup(getContext(),QMUIPopup.DIRECTION_NONE);
        TextView textView = new TextView(getContext());
        textView.setLayoutParams(mnormalPopup.generateLayoutParam(
                QMUIdisplayHelper.dp2px(getContext(),250),WRAP_CONTENT
        ));
        textView.setLinespacing(QMUIdisplayHelper.dp2px(getContext(),4),1.0f);
        int padding = QMUIdisplayHelper.dp2px(getContext(),20);
        textView.setPadding(padding,padding,padding);
        textView.setText("Popup 可以设置其位置以及显示和隐藏的动画");
        textView.setTextColor(ContextCompat.getColor(getContext(),R.color.app_color_description));
        mnormalPopup.setContentView(textView);
        mnormalPopup.setondismissListener(new PopupWindow.OndismissListener() {
            @Override
            public void ondismiss() {
                mActionButton1.setText(getContext().getResources().getString(R.string.popup_normal_action_button_text_show));
            }
        });
    }
}
项目:qmui    文件QDPopupFragment.java   
private void initnormalPopupIfNeed() {
    if (mnormalPopup == null) {
        mnormalPopup = new QMUIPopup(getContext(),R.color.app_color_description));
        mnormalPopup.setContentView(textView);
        mnormalPopup.setondismissListener(new PopupWindow.OndismissListener() {
            @Override
            public void ondismiss() {
                mActionButton1.setText(getContext().getResources().getString(R.string.popup_normal_action_button_text_show));
            }
        });
    }
}
项目:letv    文件AlbumCommentDetailActivity.java   
public void showPopupWindow(View target) {
    if (target != null) {
        if (this.morePopupWindow == null) {
            this.morePopupWindow = new PopupWindow(BaseApplication.getInstance());
            this.morePopupWindow.setBackgroundDrawable(new BitmapDrawable());
            this.morePopupWindow.setWidth(UIsUtils.zoomWidth(60));
            this.morePopupWindow.setHeight(UIsUtils.zoomWidth(40));
            this.morePopupWindow.setoutsidetouchable(true);
            this.morePopupWindow.setFocusable(true);
            this.morePopupWindow.setContentView(this.popupContentView);
        }
        int[] location = new int[2];
        target.getLocationOnScreen(location);
        LogInfo.log("Emerson","-----------location[1] = " + location[1]);
        this.morePopupWindow.showAtLocation(target,(location[1] + (target.getHeight() / 2)) - UIsUtils.dipToPx(60.0f));
        this.morePopupWindow.update();
    }
}
项目:MinimalismJotter    文件AlbumActivity.java   
/**
 * 初始化展示文件夹的popupWindw
 */
private void initListDirPopupWindw() {
    mListimageDirPopupWindow = new ListimageDirPopupWindow(
            LayoutParams.MATCH_PARENT,(int) (mScreenHeight * 0.7),mImageFloders,LayoutInflater.from(getApplicationContext())
            .inflate(R.layout.list_dir,null));

    mListimageDirPopupWindow.setondismissListener(new PopupWindow.OndismissListener() {

        @Override
        public void ondismiss() {
            // 设置背景颜色变暗
            WindowManager.LayoutParams lp = getwindow().getAttributes();
            lp.alpha = 1.0f;
            getwindow().setAttributes(lp);
        }
    });
    // 设置选择文件夹的回调
    mListimageDirPopupWindow.setonImageDirselected(this);
}
项目:mvvm-template    文件AnimHelper.java   
@UiThread public static void revealPopupWindow(@NonNull PopupWindow popupWindow,@NonNull View from) {
    Rect rect = ViewHelper.getLayoutPosition(from);
    int x = (int) rect.exactCenterX();
    int y = (int) rect.exactCenterY();
    if (popupWindow.getContentView() != null) {
        View view = popupWindow.getContentView();
        if (view != null) {
            popupWindow.showAsDropDown(from);
            view.post(() -> {
                if (ViewCompat.isAttachedToWindow(view)) {
                    Animator animator = ViewAnimationUtils.createCircularReveal(view,x,y,(float) Math.hypot(rect.width(),rect.height()));
                    animator.setDuration(view.getResources().getInteger(android.R.integer.config_shortAnimTime));
                    animator.start();
                }
            });
        }
    }
}
项目:letv    文件SweepActivity.java   
private void OpenHelpWindows() {
    this.mNottoSweep = true;
    View mDialogView = getLayoutInflater().inflate(R.layout.activity_sweep_help_viewpager,null,false);
    this.mSweepHelpView = new SweepHelpView(mDialogView);
    this.mSweepHelpView.initView();
    final PopupWindow helpPopup = DialogUtils.dialog(mDialogView,-1);
    this.mIsHelpViewShow = true;
    this.mSweepHelpView.setonCloseListener(new IFunction<Void>() {
        public Void get() {
            SweepActivity.this.mIsHelpViewShow = false;
            SweepActivity.this.initSweep();
            DialogUtils.closeDialog(helpPopup);
            SweepActivity.this.mLastObjString = null;
            if (!NetworkUtil.isNetAvailable()) {
                SweepActivity.this.mNottoSweep = true;
                if (!SweepActivity.this.mIsPermissionTipShow) {
                    SweepActivity.this.openNoNewworkTip();
                }
            }
            return null;
        }
    });
}
项目:Demos    文件FillBlankView.java   
@Override
public void onClick(final View widget) {
    View view = LayoutInflater.from(context).inflate(R.layout.layout_input,null);
    final EditText etInput = (EditText) view.findViewById(R.id.et_answer);
    Button btnFillBlank = (Button) view.findViewById(R.id.btn_fill_blank);

    // 显示原有答案
    String oldAnswer = answerList.get(position);
    if (!TextUtils.isEmpty(oldAnswer)) {
        etInput.setText(oldAnswer);
        etInput.setSelection(oldAnswer.length());
    }

    final PopupWindow popupWindow = new PopupWindow(view,LayoutParams.MATCH_PARENT,dp2px(40));
    // 获取焦点
    popupWindow.setFocusable(true);
    // 为了防止弹出菜单获取焦点之后,点击Activity的其他组件没有响应
    popupWindow.setBackgroundDrawable(new PaintDrawable());
    // 设置PopupWindow在软键盘的上方
    popupWindow.setSoftInputMode(WindowManager.LayoutParams.soFT_INPUT_ADJUST_RESIZE);
    // 弹出PopupWindow
    popupWindow.showAtLocation(tvContent,0);

    btnFillBlank.setonClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // 填写答案
            String answer = etInput.getText().toString();
            fillAnswer(answer,position);
            popupWindow.dismiss();
        }
    });

    // 显示键盘
    InputMethodManager inputMethodManager =
            (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(0,InputMethodManager.HIDE_NOT_ALWAYS);
}
项目:LQRWeChat-master    文件PopupWindowUtils.java   
/**
 * 得到在屏幕中间的popupwindow并显示(宽高都是包裹视图)
 *
 * @param contentView popupwindow要显示的视图
 * @param parentView  参考视图
 * @return
 */
public static PopupWindow getPopupWindowInCenter(View contentView,View parentView) {
    //        int width = ViewGroup.LayoutParams.MATCH_PARENT;
    int width = ViewGroup.LayoutParams.WRAP_CONTENT;
    int height = ViewGroup.LayoutParams.WRAP_CONTENT;

    return getPopupWindowInCenter(contentView,height,parentView);
}
项目:GitHub    文件ReadActivity.java   
@OnClick(R.id.tvBookReadToc)
public void onClickToc() {
    gone(rlReadAaSet,rlReadMark);
    if (!mTocListPopupWindow.isShowing()) {
        visible(mTvBookReadTocTitle);
        gone(mTvBookReadReading,mTvBookReadCommunity,mTvBookReadChangeSource);
        mTocListPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        mTocListPopupWindow.setSoftInputMode(WindowManager.LayoutParams.soFT_INPUT_ADJUST_RESIZE);
        mTocListPopupWindow.show();
        mTocListPopupWindow.setSelection(currentChapter - 1);
        mTocListPopupWindow.getListView().setFastScrollEnabled(true);
    }
}
项目:GitHub    文件FolderWindow.java   
public static void setPopupWindowTouchModal(PopupWindow popupWindow,boolean touchModal) {
    if (null == popupWindow) {
        return;
    }
    Method method;
    try {
        method = PopupWindow.class.getDeclaredMethod("setTouchModal",boolean.class);
        method.setAccessible(true);
        method.invoke(popupWindow,touchModal);
    } catch (Exception e) {
        e.printstacktrace();
    }
}
项目:GitHub    文件EasyPopActivity.java   
private void initAbovePop() {
    mAbovePop = new EasyPopup(this)
            .setContentView(R.layout.layout_any)
            .setFocusAndOutsideEnable(true)
            .setondismissListener(new PopupWindow.OndismissListener() {
                @Override
                public void ondismiss() {
                    Log.e(TAG,"ondismiss: mAbovePop");
                }
            })
            .createPopup();
}
项目:BookReader-master    文件SearchActivity.java   
@Override
public void showAutoCompleteList(List<String> list) {
    mAutoList.clear();
    mAutoList.addAll(list);

    if (!mListPopupWindow.isShowing()) {
        mListPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        mListPopupWindow.setSoftInputMode(WindowManager.LayoutParams.soFT_INPUT_ADJUST_RESIZE);
        mListPopupWindow.show();
    }
    mAutoAdapter.notifyDataSetChanged();

}
项目:FastLib    文件PopupWindowUtil.java   
/**
 * 展示popupWindow--解决Android 7.0版本兼容性问题
 *
 * @param mWindow PopupWindow
 * @param anchor  the view on which to pin the popup window
 * @param x       A horizontal offset from the anchor in pixels
 * @param y       A vertical offset from the anchor in pixels
 */
public static void showAsDropDown(PopupWindow mWindow,View anchor,int x,int y) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
        int[] location = new int[2];
        anchor.getLocationOnScreen(location);
        mWindow.showAtLocation(anchor,Gravity.NO_GraviTY,location[0] + x,location[1] + anchor.getHeight() + y);
    } else {
        mWindow.showAsDropDown(anchor,y);
    }
}
项目:Blockly    文件BasicFieldColorViewTest.java   
@Test
public void testPopupWindowProperties() {
    mFieldColorView.performClick();
    final PopupWindow popupWindow = mFieldColorView.getColorPopupWindow();

    assertthat(popupWindow).isNotNull();
    assertthat(popupWindow.isShowing()).isTrue();
    assertthat(popupWindow.isTouchable()).isTrue();
    assertthat(popupWindow.isFocusable()).isTrue();
}
项目:backup    文件RestoreBackupActivityController.java   
private PopupWindow buildPopupWindow(Activity parent) {
    LayoutInflater inflater = (LayoutInflater) parent.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    ViewGroup popupViewGroup = parent.findViewById(R.id.popup_layout);
    View popupView = inflater.inflate(R.layout.progress_popup_window,popupViewGroup);

    PopupWindow popupWindow = new PopupWindow(popupView,750,350,true);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    popupWindow.setElevation(10);
    popupWindow.setFocusable(false);
    popupWindow.showAtLocation(popupView,0);
    return popupWindow;
}
项目:boohee_v5.6    文件CustomunitPopupWindow.java   
private void createPopWindow(Context context,String unit_name) {
    if (this.mContext != context) {
        this.mContext = context;
        this.mCurrentUnitName = unit_name;
        this.popWindow = new PopupWindow(createContentView(),-2,true);
        this.popWindow.setBackgroundDrawable(new BitmapDrawable());
        this.popWindow.setFocusable(true);
        this.popWindow.setTouchable(true);
        this.popWindow.setoutsidetouchable(true);
        this.inAnim = AnimationUtils.loadAnimation(this.mContext,R.anim.s);
    }
}
项目:TextReader    文件ReadActivity.java   
@OnClick(R.id.tvBookReadToc)
public void onClickToc() {
    gone(rlReadAaSet,mTvBookReadChangeSource);
        mTocListPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        mTocListPopupWindow.setSoftInputMode(WindowManager.LayoutParams.soFT_INPUT_ADJUST_RESIZE);
        mTocListPopupWindow.show();
        mTocListPopupWindow.setSelection(currentChapter - 1);
        mTocListPopupWindow.getListView().setFastScrollEnabled(true);
    }
}
项目:CSipSimple    文件MenuPopupHelper.java   
public boolean tryShow() {
    mPopup = new IcslistPopupWindow(mContext,R.attr.popupMenuStyle);
    mPopup.setondismissListener(this);
    mPopup.setonItemClickListener(this);

    mAdapter = new MenuAdapter(mMenu);
    mPopup.setAdapter(mAdapter);
    mPopup.setModal(true);

    View anchor = mAnchorView;
    if (anchor != null) {
        // Don't attach to the VTO unless the anchor itself is attached to avoid VTO-related leaks.
        if (anchor.getwindowToken() != null) {
            ViewTreeObserver vto = anchor.getViewTreeObserver();
            if (vto != mTreeObserver) {
                if (mTreeObserver != null && mTreeObserver.isAlive()) {
                    mTreeObserver.removeGlobalOnLayoutListener(this);
                }
                if ((mTreeObserver = vto) != null) {
                    vto.addOnGlobalLayoutListener(this);
                }
            }
        } else if (anchor instanceof View_HasstateListenerSupport) {
            ((View_HasstateListenerSupport) anchor).addOnAttachStatechangelistener(this);
        }
        mPopup.setAnchorView(anchor);
    } else {
        return false;
    }

    mPopup.setContentWidth(Math.min(measureContentWidth(mAdapter),mPopupMaxWidth));
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    mPopup.show();
    mPopup.getListView().setonKeyListener(this);
    return true;
}
项目:android-project-gallery    文件BaseFragmentActivity.java   
/**
 * 显示底部菜单栏
 * 
 * @param popupWindow
 */
public void showBottomPopupMenu(final PopupWindow popupWindow,final int background)
{
    popupWindow.showAtLocation(rocky_rootView,0);
    getUiHandler().postDelayed(new Runnable()
    {

        @Override
        public void run()
        {
            setBottomPopupMenuBackground(background);
            setBottomPopupMenuVisibility(View.VISIBLE);
        }
    },500);
}
项目:FamilyBond    文件CustomPopupWindow.java   
private CustomPopupWindow(Builder builder) {

        if (builder.contentViewId == 0 || builder.width == 0 || builder.height == 0) {
            throw new IllegalArgumentException("The parameter is incomplete,be sure to contain contentView,width and height.");
        }

        mContext = builder.context;
        mContentView = LayoutInflater.from(mContext).inflate(builder.contentViewId,null);
        mPopupWindow = new PopupWindow(mContentView,builder.width,builder.height,builder.focus);

        if (Build.VERSION.SDK_INT >= 21) mPopupWindow.setElevation(builder.elevation);
        mPopupWindow.setoutsidetouchable(builder.outsideCancel);
        mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        mPopupWindow.setAnimationStyle(builder.animstyle);
    }
项目:android-project-gallery    文件BaseFragmentActivity.java   
/**
 * 隐藏底部菜单栏
 * 
 * @param popupWindow
 */
public void dismissBottomPopupMenu(final PopupWindow popupWindow)
{
    setBottomPopupMenuVisibility(View.GONE);
    getUiHandler().post(new Runnable()
    {

        @Override
        public void run()
        {
            popupWindow.dismiss();
        }
    });
}
项目:CSipSimple    文件IcslistPopupWindow.java   
public void run() {
    if (mDropDownList != null && mDropDownList.getCount() > mDropDownList.getChildCount() &&
            mDropDownList.getChildCount() <= mListItemExpandMaximum) {
        mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
        show();
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。