List of usage examples for android.widget PopupWindow setWidth
public void setWidth(int width)
From source file:org.zywx.wbpalmstar.plugin.uexscrawl.PhotoScrawlActivity.java
private void showPopWindow(SeekBar seekBar, View relativeView) { int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); seekBar.measure(w, h);/*from w w w .j av a 2 s . c o m*/ PopupWindow popupWindow = new PopupWindow(seekBar); popupWindow.setBackgroundDrawable(new ColorDrawable()); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.setWidth(seekBar.getMeasuredWidth()); popupWindow.setHeight(EUExUtil.dipToPixels(120)); popupWindow.showAtLocation(mImageContentLayout, Gravity.BOTTOM, relativeView.getLeft() - mImageContentLayout.getWidth() / 2 + relativeView.getWidth() / 2, mCloseLayout.getHeight() + relativeView.getHeight() + 50); }
From source file:org.zywx.wbpalmstar.plugin.uexscrawl.PhotoScrawlActivity.java
private void showColorChoosePop() { LinearLayout linearLayout = new LinearLayout(this); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); int margin = EUExUtil.dipToPixels(8); lp.setMargins(margin / 2, margin, margin / 2, margin); linearLayout.setLayoutParams(lp);/* w w w.j ava 2 s . c o m*/ linearLayout.setOrientation(LinearLayout.HORIZONTAL); for (int color : colors) { linearLayout.addView(getColorImageView(color)); } HorizontalScrollView scrollView = new HorizontalScrollView(this); LinearLayout.LayoutParams scrollLp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); scrollView.setLayoutParams(scrollLp); scrollView.addView(linearLayout); int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); scrollView.measure(w, h); PopupWindow popupWindow = new PopupWindow(scrollView); popupWindow.setBackgroundDrawable(new ColorDrawable()); popupWindow.setFocusable(true); popupWindow.setOutsideTouchable(true); popupWindow.setWidth(mImageContentLayout.getWidth()); popupWindow.setHeight(scrollView.getMeasuredHeight()); popupWindow.showAtLocation(mImageContentLayout, Gravity.BOTTOM, 0, mCloseLayout.getHeight() + mBrushLayout.getHeight() + popupWindow.getHeight()); }
From source file:ab.util.AbDialogUtil.java
/** * /*from ww w .j ava 2 s. c o m*/ */ public static MyPop showDatePopWindowHour(Context context, View contentView, View targetView) { // hourArrayString = getHMArray(24); // ?? c = Calendar.getInstance(); PopupWindow popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.BLACK)); popupWindow.setWidth(context.getResources().getDisplayMetrics().widthPixels); popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0); hourWV = (WheelView) contentView.findViewById(R.id.time_hour); // ? hourWV.setVisibleItems(5); // hourWV.setLabel(":00"); hourWV.setCyclic(true); setHourData(); return new MyPop(popupWindow, yearWV, monthWV, dayWV, hourWV, minuteWV); }
From source file:ab.util.AbDialogUtil.java
public static MyPop showDatePopWindow(Context context, View contentView, View targetView) { // // ww w . j a v a 2s . c o m yearArrayString = getYEARArray(2016, 30); monthArrayString = getDayArray(12); hourArrayString = getHMArray(24); minuteArrayString = getHMArray(60); // ?? c = Calendar.getInstance(); PopupWindow popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); popupWindow.setWidth(context.getResources().getDisplayMetrics().widthPixels); popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0); yearWV = (WheelView) contentView.findViewById(R.id.time_year); monthWV = (WheelView) contentView.findViewById(R.id.time_month); dayWV = (WheelView) contentView.findViewById(R.id.time_day); hourWV = (WheelView) contentView.findViewById(R.id.time_hour); minuteWV = (WheelView) contentView.findViewById(R.id.time_minute); // ? yearWV.setVisibleItems(5); monthWV.setVisibleItems(5); dayWV.setVisibleItems(5); hourWV.setVisibleItems(5); minuteWV.setVisibleItems(5); // yearWV.setLabel(""); monthWV.setLabel(""); dayWV.setLabel(""); hourWV.setLabel(""); minuteWV.setLabel(""); yearWV.setCyclic(true); monthWV.setCyclic(true); dayWV.setCyclic(true); hourWV.setCyclic(true); minuteWV.setCyclic(true); setData(); return new MyPop(popupWindow, yearWV, monthWV, dayWV, hourWV, minuteWV); }
From source file:ab.util.AbDialogUtil.java
/** * /*from ww w .j a v a2s . c o m*/ */ public static MyPop showDatePopWindowDate(Context context, View contentView, View targetView) { // yearArrayString = getYEARArray(2016, 36); monthArrayString = getDayArray(12); hourArrayString = getHMArray(24); minuteArrayString = getHMArray(60); // ?? c = Calendar.getInstance(); PopupWindow popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.BLACK)); popupWindow.setWidth(context.getResources().getDisplayMetrics().widthPixels); popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0); yearWV = (WheelView) contentView.findViewById(R.id.time_year); monthWV = (WheelView) contentView.findViewById(R.id.time_month); dayWV = (WheelView) contentView.findViewById(R.id.time_day); hourWV = (WheelView) contentView.findViewById(R.id.time_hour); minuteWV = (WheelView) contentView.findViewById(R.id.time_minute); hourWV.setVisibility(View.GONE); minuteWV.setVisibility(View.GONE); // ? yearWV.setVisibleItems(5); monthWV.setVisibleItems(5); dayWV.setVisibleItems(5); hourWV.setVisibleItems(5); minuteWV.setVisibleItems(5); // yearWV.setLabel(""); monthWV.setLabel(""); dayWV.setLabel(""); hourWV.setLabel(""); minuteWV.setLabel(""); yearWV.setCyclic(true); monthWV.setCyclic(true); dayWV.setCyclic(true); hourWV.setCyclic(true); minuteWV.setCyclic(true); setData(); return new MyPop(popupWindow, yearWV, monthWV, dayWV, hourWV, minuteWV); }
From source file:ab.util.AbDialogUtil.java
/** * popupwindow// w w w . j a va 2 s .co m */ public static PopupWindow showPopWindow(Context context, View targetView, View contentView, Integer width) { PopupWindow popupWindow = null; popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); if (width != null) { popupWindow.setWidth(width); } popupWindow.setOutsideTouchable(true); popupWindow.showAsDropDown(targetView); return popupWindow; }
From source file:ab.util.AbDialogUtil.java
/** * popupwindow/*from w ww. j ava 2 s . c o m*/ */ public static PopupWindow showPopWindow2(Context context, View targetView, View contentView, Integer width) { PopupWindow popupWindow = null; popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); if (width != null) { popupWindow.setWidth(width); } popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0); return popupWindow; }
From source file:ab.util.AbDialogUtil.java
/** * popupwindow// ww w .jav a2 s . c o m */ public static PopupWindow showPopWindow3(Context context, View targetView, View contentView, Integer width) { PopupWindow popupWindow = null; popupWindow = new PopupWindow(contentView, -2, -2); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); if (width != null) { popupWindow.setWidth(width); } popupWindow.setOutsideTouchable(true); popupWindow.showAtLocation(targetView, Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0); return popupWindow; }
From source file:com.zhangyp.higo.drawingboard.fragment.SketchFragment.java
private void showPopup(View anchor, final int eraserOrStroke) { boolean isErasing = eraserOrStroke == SketchView.ERASER; oldColor = mColorPicker.getColor();/*w w w . j a va2s . c o m*/ DisplayMetrics metrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); // Creating the PopupWindow PopupWindow popup = new PopupWindow(getActivity()); popup.setContentView(isErasing ? popupEraserLayout : popupLayout); popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT); popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT); popup.setFocusable(true); popup.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { if (mColorPicker.getColor() != oldColor) mColorPicker.setOldCenterColor(oldColor); } }); // Clear the default translucent background popup.setBackgroundDrawable(new BitmapDrawable()); // Displaying the popup at the specified location, + offsets (transformed // dp to pixel to support multiple screen sizes) popup.showAsDropDown(anchor); // Stroke size seekbar initialization and event managing SeekBar mSeekBar; mSeekBar = (SeekBar) (isErasing ? popupEraserLayout.findViewById(R.id.stroke_seekbar) : popupLayout.findViewById(R.id.stroke_seekbar)); mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { @Override public void onStopTrackingTouch(SeekBar seekBar) { } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // When the seekbar is moved a new size is calculated and the new shape // is positioned centrally into the ImageView setSeekbarProgress(progress, eraserOrStroke); } }); int progress = isErasing ? seekBarEraserProgress : seekBarStrokeProgress; mSeekBar.setProgress(progress); }
From source file:com.vanisty.ui.MenuActivity.java
private void showPopup(final Activity context, Point p) { int popupWidth = 200; int popupHeight = 150; // Inflate the popup_layout.xml LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.popup); LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = layoutInflater.inflate(R.layout.popup_layout, viewGroup); // Creating the PopupWindow final PopupWindow popup = new PopupWindow(context); popup.setContentView(layout);/*ww w.ja v a 2s. c o m*/ popup.setWidth(popupWidth); popup.setHeight(popupHeight); popup.setFocusable(true); // Some offset to align the popup a bit to the right, and a bit down, relative to button's position. int OFFSET_X = 30; int OFFSET_Y = 30; // Clear the default translucent background popup.setBackgroundDrawable(new BitmapDrawable()); // Displaying the popup at the specified location, + offsets. popup.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y + OFFSET_Y); // Getting a reference to Close button, and close the popup when clicked. Button close = (Button) layout.findViewById(R.id.close); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { popup.dismiss(); } }); }