List of usage examples for android.widget PopupWindow PopupWindow
public PopupWindow(View contentView)
Create a new non focusable popup window which can display the contentView.
From source file:com.mattermost.service.Promise.java
public static PopupWindow show() { Activity currentActivity = AppActivity.current; PopupWindow pw = new PopupWindow(currentActivity); pw.setFocusable(false);/* ww w . j a va 2s. c om*/ pw.setBackgroundDrawable(new ColorDrawable(0)); ImageView img = new ImageView(currentActivity); pw.setContentView(img); View view = currentActivity.getWindow().getDecorView(); pw.setWidth(60); pw.setHeight(60); AnimatedCircleDrawable a = new AnimatedCircleDrawable(Color.RED, 5, Color.TRANSPARENT, 30); img.setImageDrawable(a); pw.showAtLocation(view, Gravity.LEFT | Gravity.TOP, view.getWidth() / 2 - 30, view.getHeight() / 2 - 30); a.start(); return pw; }
From source file:ac.robinson.bettertogether.QRPopupWindow.java
@SuppressLint("InflateParams") QRPopupWindow(View anchorView) {/*w ww. jav a2 s. co m*/ mAnchorView = anchorView; mWindowManager = (WindowManager) mAnchorView.getContext().getSystemService(Context.WINDOW_SERVICE); mPopupWindow = new PopupWindow(mAnchorView.getContext()); LayoutInflater inflater = (LayoutInflater) mAnchorView.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); mPopupWindow.setContentView(inflater.inflate(R.layout.dialog_qr_code, null)); mPopupWindow.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { dismissPopUp(); return true; } }); }
From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewWithMiniKeyboard.java
public AnyKeyboardViewWithMiniKeyboard(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mMiniKeyboardPopup = new PopupWindow(context.getApplicationContext()); CompatUtils.setPopupUnattachedToDecor(mMiniKeyboardPopup); mMiniKeyboardPopup.setBackgroundDrawable(null); mMiniKeyboardPopup.setAnimationStyle( (mAnimationLevel == AskPrefs.AnimationsLevel.None) ? 0 : R.style.MiniKeyboardAnimation); }
From source file:edu.ptu.navpattern.tooltip.Tooltip.java
private Tooltip(Builder builder) { isCancelable = builder.isCancelable; isDismissOnClick = builder.isDismissOnClick; mGravity = builder.mGravity;//from w w w. j av a2 s . co m mMargin = builder.mMargin; mAnchorView = builder.mAnchorView; mOnDismissListener = builder.mOnDismissListener; mPopupWindow = new PopupWindow(builder.mContext); mPopupWindow.setBackgroundDrawable(null); mPopupWindow.setClippingEnabled(false); mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); mPopupWindow.setContentView(getContentView(builder)); mPopupWindow.setOutsideTouchable(builder.isCancelable); mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { mAnchorView.removeOnAttachStateChangeListener(mOnAttachStateChangeListener); if (mOnDismissListener != null) { mOnDismissListener.onDismiss(); } } }); }
From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java
@Override public void onClearSelected() { closeMenu();/*from w w w .j av a 2s. c o m*/ LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inf.inflate(R.layout.popclear_layout, null, false); final PopupWindow pw = new PopupWindow(v); pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT); pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT); TextView yesTxt = (TextView) v.findViewById(R.id.dlgYes); TextView noTxt = (TextView) v.findViewById(R.id.dlgNo); noTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); } }); yesTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); pinTableFrag.clearBoard(); } }); pw.showAtLocation(v, Gravity.CENTER, 0, 0); }
From source file:com.tooltip.Tooltip.java
private Tooltip(Builder builder) { isCancelable = builder.isCancelable; isDismissOnClick = builder.isDismissOnClick; mGravity = builder.mGravity;/*from www.j a va 2s . c om*/ mMargin = builder.mMargin; mAnchorView = builder.mAnchorView; mOnClickListener = builder.mOnClickListener; mOnLongClickListener = builder.mOnLongClickListener; mOnDismissListener = builder.mOnDismissListener; mPopupWindow = new PopupWindow(builder.mContext); mPopupWindow.setBackgroundDrawable(null); mPopupWindow.setClippingEnabled(false); mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT); mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); mPopupWindow.setContentView(getContentView(builder)); mPopupWindow.setOutsideTouchable(builder.isCancelable); mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { mAnchorView.removeOnAttachStateChangeListener(mOnAttachStateChangeListener); if (mOnDismissListener != null) { mOnDismissListener.onDismiss(); } } }); }
From source file:com.hippo.widget.Slider.java
@SuppressWarnings("deprecation") private void init(Context context, AttributeSet attrs) { mContext = context;/*from w ww . j a va 2s. c o m*/ mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG); textPaint.setTextAlign(Paint.Align.CENTER); Resources resources = context.getResources(); mBubbleMinWidth = resources.getDimensionPixelOffset(R.dimen.slider_bubble_width); mBubbleMinHeight = resources.getDimensionPixelOffset(R.dimen.slider_bubble_height); mBubble = new BubbleView(context, textPaint); mBubble.setScaleX(0.0f); mBubble.setScaleY(0.0f); AbsoluteLayout absoluteLayout = new AbsoluteLayout(context); absoluteLayout.addView(mBubble); absoluteLayout.setBackgroundDrawable(null); mPopup = new PopupWindow(absoluteLayout); mPopup.setOutsideTouchable(false); mPopup.setTouchable(false); mPopup.setFocusable(false); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Slider); textPaint.setColor(a.getColor(R.styleable.Slider_textColor, Color.WHITE)); textPaint.setTextSize(a.getDimensionPixelSize(R.styleable.Slider_textSize, 12)); updateTextSize(); setRange(a.getInteger(R.styleable.Slider_start, 0), a.getInteger(R.styleable.Slider_end, 0)); setProgress(a.getInteger(R.styleable.Slider_slider_progress, 0)); mThickness = a.getDimension(R.styleable.Slider_thickness, 2); mRadius = a.getDimension(R.styleable.Slider_radius, 6); setColor(a.getColor(R.styleable.Slider_color, Color.BLACK)); mBgPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mBgPaint.setColor(a.getBoolean(R.styleable.Slider_dark, false) ? 0x4dffffff : 0x42000000); a.recycle(); mProgressAnimation = new ValueAnimator(); mProgressAnimation.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR); mProgressAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(@NonNull ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); mDrawPercent = value; mDrawProgress = Math.round(MathUtils.lerp((float) mStart, mEnd, value)); updateBubblePosition(); mBubble.setProgress(mDrawProgress); invalidate(); } }); mBubbleScaleAnimation = new ValueAnimator(); mBubbleScaleAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(@NonNull ValueAnimator animation) { float value = (Float) animation.getAnimatedValue(); mDrawBubbleScale = value; mBubble.setScaleX(value); mBubble.setScaleY(value); invalidate(); } }); }
From source file:com.survivingwithandroid.pegboard.DreamPinsActivity.java
@Override public void onSaveSelected() { closeMenu();// ww w . j ava2 s .c o m LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inf.inflate(R.layout.popsave_layout, null, false); final PopupWindow pw = new PopupWindow(v); pw.setFocusable(true); pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT); pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT); final EditText edt = (EditText) v.findViewById(R.id.edtFileName); TextView saveTxt = (TextView) v.findViewById(R.id.dlgSave); TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel); cancelTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); } }); saveTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); Bitmap b = pinTableFrag.createBitmap(); try { ImageUtility.saveImage(b, edt.getEditableText().toString(), DreamPinsActivity.this); } catch (SaveFileException sfe) { Toast.makeText(DreamPinsActivity.this, getResources().getText(R.string.msgSaveFileError), Toast.LENGTH_LONG).show(); } } }); pw.showAtLocation(v, Gravity.CENTER, 0, 0); }
From source file:com.zipzapd.DreamPinsActivity.java
@Override public void onSaveSelected() { closeMenu();//from w ww . j ava 2s. c om LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inf.inflate(R.layout.popsave_layout, null, false); final PopupWindow pw = new PopupWindow(v); pw.setFocusable(true); pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT); pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT); final EditText edt = (EditText) v.findViewById(R.id.edtFileName); TextView saveTxt = (TextView) v.findViewById(R.id.dlgSave); TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel); cancelTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); } }); saveTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); Bitmap b = pinTableFrag.createBitmap(); try { /////////////// ImageUtility.saveImage(b, edt.getEditableText().toString(), DreamPinsActivity.this); sync.putZipZapData(); /////////////// } catch (SaveFileException sfe) { Toast.makeText(DreamPinsActivity.this, getResources().getText(R.string.msgSaveFileError), Toast.LENGTH_LONG).show(); } } }); pw.showAtLocation(v, Gravity.CENTER, 0, 0); }
From source file:com.survivingwithandroid.pegboard1.DreamPinsActivity.java
@Override public void onSaveSelected() { closeMenu();// w ww . j a v a 2 s . c o m LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inf.inflate(R.layout.popsave_layout, null, false); final PopupWindow pw = new PopupWindow(v); pw.setFocusable(true); pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT); pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT); final EditText edt = (EditText) v.findViewById(R.id.edtFileName); TextView saveTxt = (TextView) v.findViewById(R.id.dlgSave); TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel); cancelTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); } }); saveTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pw.dismiss(); Bitmap b = pinTableFrag.createBitmap(); try { /////////////// ImageUtility.saveImage(b, edt.getEditableText().toString(), DreamPinsActivity.this); /////////////// } catch (SaveFileException sfe) { Toast.makeText(DreamPinsActivity.this, getResources().getText(R.string.msgSaveFileError), Toast.LENGTH_LONG).show(); } } }); pw.showAtLocation(v, Gravity.CENTER, 0, 0); }