Example usage for android.widget PopupWindow setBackgroundDrawable

List of usage examples for android.widget PopupWindow setBackgroundDrawable

Introduction

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

Prototype

public void setBackgroundDrawable(Drawable background) 

Source Link

Document

Specifies the background drawable for this popup window.

Usage

From source file:Main.java

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);//from ww w . j  a  va  2s . c  o m
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAsDropDown(targetView);
    return popupWindow;
}

From source file:Main.java

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);//from  w  w w  .  ja v a  2s .c  o  m
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0);
    return popupWindow;
}

From source file:Main.java

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);//from  w  ww  . j  a v a 2  s . co m
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
    return popupWindow;
}

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  av  a2s . 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.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);/*www .j a v a 2 s . c  o  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:com.android.talkbacktests.testsession.PopupViewTest.java

/**
 * Shows a PopupWindow at the anchor view with given window height and list size.
 *///ww w . j a  va 2s . co m
private void showPopupWindow(View button, int height, int listSize, boolean useDefaultInflater) {
    final Context context = button.getContext();
    final ListView listView = new ListView(context);
    final BaseAdapter adapter;
    if (useDefaultInflater) {
        adapter = new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, android.R.id.text1,
                createSampleArray(listSize));
    } else {
        adapter = new MyAdapter(button.getContext(), createSampleArray(listSize));
    }
    listView.setAdapter(adapter);

    listView.setVerticalScrollBarEnabled(true);
    listView.setBackgroundColor(0xFFFFFF);
    final PopupWindow window = new PopupWindow(listView, ViewGroup.LayoutParams.WRAP_CONTENT, height, true);
    window.setBackgroundDrawable(context.getResources().getDrawable(android.R.drawable.editbox_background));
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (window.isShowing()) {
                window.dismiss();
            }
        }
    });
    PopupWindowCompat.showAsDropDown(window, button, 0, 0, Gravity.NO_GRAVITY);
}

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 a  va 2s.  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);/*ww w  . j a  v 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:fr.univsavoie.ltp.client.map.Popup.java

/**
  * Afficher sur la map un popup qui affiche les
  * informations de l'utilisateur connect.
  *///ww w  . j a  v a2s . c om
public final void popupDisplayUserInfos() {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;

    int popupWidth = (int) (width * 0.75);
    //int popupHeight = height / 2;

    // Inflate the popup_layout.xml
    LinearLayout viewGroup = (LinearLayout) this.activity.findViewById(R.id.popupAccount);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_account, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupUserInfos = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupUserInfos.setBackgroundDrawable(new BitmapDrawable());
    popupUserInfos.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupUserInfos.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Ecouteur d'vnement sur le bouton pour se dconnecter
    Button close = (Button) layout.findViewById(R.id.close);
    close.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            popupUserInfos.dismiss();
        }
    });
}

From source file:fr.univsavoie.ltp.client.map.Popup.java

/**
 * Afficher sur la map un popup qui propose a l'utilisateur
 * de mettre a jours son status/*from   www  . java 2 s .co m*/
 */
public final void popupPublishStatus() {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;

    int popupWidth = (int) (width * 0.75);
    //int popupHeight = height / 2;

    // Inflate the popup_layout.xml
    ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupStatus);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_set_status, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupPublishStatus.setBackgroundDrawable(new BitmapDrawable());
    popupPublishStatus.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Ecouteur d'vnement sur le bouton pour se dconnecter
    Button publish = (Button) layout.findViewById(R.id.btStatusPublish);
    publish.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            EditText userStatus = (EditText) layout.findViewById(R.id.fieldUserStatus);
            if (userStatus.getText().toString().length() == 0) {
                Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();
            } else if (userStatus.getText().toString().length() < 3) {
                Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();
            } else {
                String json = "{\"ltp\":{\"application\":\"Client LTP\",\"status\":{\"lon\" : \""
                        + String.valueOf(activity.getLongitude()) + "\",\"lat\" : \""
                        + String.valueOf(activity.getLatitude()) + "\",\"content\" : \""
                        + userStatus.getText().toString() + "\"}}}";
                activity.getSession().postJSON("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses",
                        "STATUSES", json);

                Toast.makeText(activity, "Status mise a jours !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();

                // Actualise les marqueurs
                activity.displayFriends();
            }
        }
    });
}