Example usage for android.widget PopupWindow setWindowLayoutMode

List of usage examples for android.widget PopupWindow setWindowLayoutMode

Introduction

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

Prototype

@Deprecated
public void setWindowLayoutMode(int widthSpec, int heightSpec) 

Source Link

Document

Change the width and height measure specs that are given to the window manager by the popup.

Usage

From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java

public static void fullscreen(android.support.v4.app.Fragment fragment, JSONParcelable imageData,
        PopupWindow popupWindow, View mainView) {
    popupWindow.setBackgroundDrawable(new ColorDrawable(0x80000000));
    popupWindow.setFocusable(true);/*from  w w  w .  ja v a2  s  .co  m*/
    popupWindow.setWindowLayoutMode(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    final ZoomableImageView zoomableImageView = new ZoomableImageView(fragment.getActivity());
    popupWindow.setContentView(zoomableImageView);
    popupWindow.showAtLocation(mainView, Gravity.TOP, 0, 0);
    LoadImageAsync loadImageAsync = new LoadImageAsync(zoomableImageView, imageData);
    loadImageAsync.execute();
}

From source file:org.onebusaway.android.ui.ArrivalsListHeader.java

/**
 * Sets the popup for the status/*  w w w.  j av a 2 s .co m*/
 *
 * @param index      0 if this is for the top ETA row, 1 if it is for the second
 * @param color      color resource id to use for the popup background
 * @param statusText text to show in the status popup
 * @return a new PopupWindow initialized based on the provided parameters
 */
private PopupWindow setupPopup(final int index, int color, String statusText) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    TextView statusView = (TextView) inflater.inflate(R.layout.arrivals_list_tv_template_style_b_status_large,
            null);
    statusView.setBackgroundResource(R.drawable.round_corners_style_b_status);
    GradientDrawable d = (GradientDrawable) statusView.getBackground();
    if (color != R.color.stop_info_ontime) {
        // Show early/late color
        d.setColor(mResources.getColor(color));
    } else {
        // For on-time, use header default color
        d.setColor(mResources.getColor(R.color.theme_primary));
    }
    d.setStroke(UIUtils.dpToPixels(mContext, 1), mResources.getColor(R.color.header_text_color));
    int pSides = UIUtils.dpToPixels(mContext, 5);
    int pTopBottom = UIUtils.dpToPixels(mContext, 2);
    statusView.setPadding(pSides, pTopBottom, pSides, pTopBottom);
    statusView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    statusView.measure(TextView.MeasureSpec.UNSPECIFIED, TextView.MeasureSpec.UNSPECIFIED);
    statusView.setText(statusText);
    PopupWindow p = new PopupWindow(statusView, statusView.getWidth(), statusView.getHeight());
    p.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    p.setBackgroundDrawable(new ColorDrawable(mResources.getColor(android.R.color.transparent)));
    p.setOutsideTouchable(true);
    p.setTouchInterceptor(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            boolean touchInView;
            if (index == 0) {
                touchInView = UIUtils.isTouchInView(mEtaAndMin1, event);
            } else {
                touchInView = UIUtils.isTouchInView(mEtaAndMin2, event);
            }
            return touchInView;
        }
    });
    return p;
}