@Override public void showLithoTooltip( View container, Rect anchorBounds, int xOffset, int yOffset) { popupWindow.showAsDropDown( container, anchorBounds.left + xOffset, anchorBounds.bottom + yOffset); } },
@Override public void showBottomLeft(View anchor, int xOffset, int yOffset) { popupWindow.showAsDropDown(anchor, xOffset, yOffset); } },
@Override public void showAsDropDown(View anchor, int xoff, int yoff) { if (Build.VERSION.SDK_INT < 21 && mOverlapAnchor) { // If we're pre-L, emulate overlapAnchor by modifying the yOff yoff -= anchor.getHeight(); } super.showAsDropDown(anchor, xoff, yoff); }
@TargetApi(Build.VERSION_CODES.KITKAT) @Override public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) { if (Build.VERSION.SDK_INT < 21 && mOverlapAnchor) { // If we're pre-L, emulate overlapAnchor by modifying the yOff yoff -= anchor.getHeight(); } super.showAsDropDown(anchor, xoff, yoff, gravity); }
@Override public void showAsDropDown(View anchor, int xoff, int yoff) { lightoff(); super.showAsDropDown(anchor, xoff, yoff); }
@Override public void showAsDropDown(View anchor, int xoff, int yoff) { lightoff(); super.showAsDropDown(anchor, xoff, yoff); }
/** * 得到在指定某个视图外的popupwindow并显示 * * @param contentView popupwindow要显示的视图 * @param width popupwindow的宽度 * @param height popupwindow的高度 * @param anchorView 参考视图 * @param xoff x轴偏移量 * @param yoff y轴偏移量 * @return */ public static PopupWindow getPopupWindowAsDropDown(View contentView, int width, int height, View anchorView, int xoff, int yoff) { PopupWindow popupWindow = getPopupWindow(contentView, width, height); popupWindow.showAsDropDown(anchorView, xoff, yoff); return popupWindow; }
PopupWindow pw; LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.weight_popup, (ViewGroup)findViewById(R.id.linlay_weight_popup)); pw = new PopupWindow(layout,LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT, true); pw.setBackgroundDrawable(new BitmapDrawable()); pw.setOutsideTouchable(true); pw.showAsDropDown(btnSelectWeight);
/** * 得到在指定某个视图外的popupwindow并显示(该方法只支持4.4以上) * * @param contentView popupwindow要显示的视图 * @param width popupwindow的宽度 * @param height popupwindow的高度 * @param anchorView 参考视图 * @param gravityType 在参考视图外的相对位置 * @param xoff x轴偏移量 * @param yoff y轴偏移量 * @return */ @TargetApi(Build.VERSION_CODES.KITKAT) public static PopupWindow getPopupWindowAsDropDown(View contentView, int width, int height, View anchorView, int gravityType, int xoff, int yoff) { PopupWindow popupWindow = getPopupWindow(contentView, width, height); popupWindow.showAsDropDown(anchorView, xoff, yoff, gravityType); return popupWindow; }
/** * 得到一个自动识别在目标控件上方或下方的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, 0); } else {// 显示popupwindow在itemView的上方,偏移量y都为-2*itemView.getHeight() popupWindow.showAsDropDown(anchorView, 0, -2 * anchorView.getHeight()); } return popupWindow; }
PopupWindow popup = new PopupWindow(contentView, width, height); popup.setBackgroundDrawable(null); popup.showAsDropDown(anchor); WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams p = (WindowManager.LayoutParams) contentView.getLayoutParams(); p.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND; p.dimAmount = 0.3f; wm.updateViewLayout(contentView, p);
@OnClick(R.id.more) public void more(View view) { View popupView = mInflater.inflate(R.layout.popup_reply, null); popupView.findViewById(R.id.favour).setOnClickListener(this); popupView.findViewById(R.id.comment).setOnClickListener(this); window = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); window.setOutsideTouchable(true); window.setFocusable(true); window.setAnimationStyle(R.style.popup_more_anim); window.setBackgroundDrawable(new ColorDrawable(Color.BLACK)); popupView.measure(0, 0); int xoff = -popupView.getMeasuredWidth(); int yoff = -(popupView.getMeasuredHeight() + view.getHeight()) / 2; window.showAsDropDown(view, xoff, yoff); }
PopupWindow popup = new PopupWindow(contentView, width, height); popup.setBackgroundDrawable(background); popup.showAsDropDown(anchor); View container = (View) popup.getContentView().getParent(); WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams p = (WindowManager.LayoutParams) container.getLayoutParams(); p.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND; p.dimAmount = 0.3f; wm.updateViewLayout(container, p);
public void showDropDown() { if (!isArrowHidden) { animateArrow(true); } measurePopUpDimension(); popupWindow.showAsDropDown(this); }
mPopupContent.getMeasuredWidth(), mPopupContent.getMeasuredHeight()); mPopupWindow.showAsDropDown(mAnchorViewRef.get()); updateArrows(); if (mNuxDisplayTime > 0) {
_p.setFocusable(true); _p.setOutsideTouchable(true); _p.showAsDropDown(view);
clarityPopWindow.showAsDropDown(clarity); layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); int offsetX = clarity.getMeasuredWidth() / 3;
int size = (int) UIUtils.convertDpToPixel(144, v.getContext()); mPopup = new PopupWindow(imageView, size, size); mPopup.showAsDropDown(v);
void popup(View view, String text) { int width = view.getMeasuredWidth(); int height = view.getMeasuredHeight(); Button button = new Button(getContext(), null, android.R.attr.buttonBarButtonStyle); button.setText(text); button.setTextColor(TEXT_COLOR); button.setPadding(0, 0, 0, 0); button.setMinHeight(0); button.setMinWidth(0); button.setMinimumWidth(0); button.setMinimumHeight(0); button.setWidth(width); button.setHeight(height); button.setBackgroundColor(BUTTON_PRESSED_COLOR); popupWindow = new PopupWindow(this); popupWindow.setWidth(LayoutParams.WRAP_CONTENT); popupWindow.setHeight(LayoutParams.WRAP_CONTENT); popupWindow.setContentView(button); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(false); popupWindow.showAsDropDown(view, 0, -2 * height); }
@Override public void onRightClick(View view) { if (mQQPop != null) { mQQPop.showAsDropDown(view, -mQQPop.getContentView().getWidth() + SizeUtils.dp2px(30), 0); } }