Example usage for android.widget PopupWindow setHeight

List of usage examples for android.widget PopupWindow setHeight

Introduction

In this page you can find the example usage for android.widget PopupWindow setHeight.

Prototype

public void setHeight(int height) 

Source Link

Document

Sets the popup's requested height.

Usage

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 ava  2  s.  c  o m*/
    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:com.survivingwithandroid.pegboard.DreamPinsActivity.java

@Override
public void onClearSelected() {

    closeMenu();/*from  w ww .  j  a  va  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.survivingwithandroid.pegboard.DreamPinsActivity.java

@Override
public void onSaveSelected() {
    closeMenu();//from ww  w  .jav a  2 s. 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);
            } 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.pegboard.DreamPinsActivity.java

public void onBackgroundSelected() {
    LayoutInflater inf = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inf.inflate(R.layout.popbkg_layout, null, false);

    final PopupWindow pw = new PopupWindow(v);
    pw.setFocusable(true);/* w  w  w.  j ava 2 s  .  com*/
    pw.setWidth(RelativeLayout.LayoutParams.WRAP_CONTENT);
    pw.setHeight(RelativeLayout.LayoutParams.WRAP_CONTENT);

    TextView changeTxt = (TextView) v.findViewById(R.id.dlgChange);
    TextView resetTxt = (TextView) v.findViewById(R.id.dlgReset);
    TextView cancelTxt = (TextView) v.findViewById(R.id.dlgCancel);
    cancelTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
        }
    });

    resetTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            pinTableFrag.setBackground(R.drawable.tilebkg);
        }
    });

    changeTxt.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            pw.dismiss();
            // Start a new Intent to get the picture from the Gallery
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(intent, SELECT_PICTURE);
        }
    });

    pw.showAtLocation(v, Gravity.CENTER, 0, 0);

}

From source file:com.survivingwithandroid.pegboard1.DreamPinsActivity.java

@Override
public void onSaveSelected() {
    closeMenu();/*from ww w  .  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);

}

From source file:com.zipzapd.DreamPinsActivity.java

@Override
public void onSaveSelected() {
    closeMenu();/*  w  w w.  ja v a 2  s.co 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);

                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.dycody.android.idealnote.SketchFragment.java

private void showPopup(View anchor, final int eraserOrStroke) {

    boolean isErasing = eraserOrStroke == SketchView.ERASER;

    oldColor = mColorPicker.getColor();//  w w  w .  ja  v  a  2s .c om

    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(() -> {
        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: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);/*  w  w w .ja va  2s  .c om*/
    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);//ww  w. j av a  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:com.zhangyp.higo.drawingboard.fragment.SketchFragment.java

private void showPopup(View anchor, final int eraserOrStroke) {

    boolean isErasing = eraserOrStroke == SketchView.ERASER;

    oldColor = mColorPicker.getColor();/*from  w  w  w.  ja v a 2s.c om*/

    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);
}