Example usage for android.widget PopupWindow showAtLocation

List of usage examples for android.widget PopupWindow showAtLocation

Introduction

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

Prototype

@UnsupportedAppUsage
public void showAtLocation(IBinder token, int gravity, int x, int y) 

Source Link

Document

Display the content view in a popup window at the specified location.

Usage

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);// w  w  w.  j a va 2 s .  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 w  w. ja  v  a  2  s . c om*/
    }
    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);//from  w  w w  .j a va 2 s.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: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.jav 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.ymt.demo1.plates.knowledge.KnowledgeMainActivity.java

protected void initTitle() {
    final MyTitle title = (MyTitle) findViewById(R.id.my_title);
    //        title.setTitleStyle(MyTitle.TitleStyle.RIGHT_ICON_L_R);
    //todo ? ?UI//  w  ww . j  a  v  a2  s .c  om
    title.setTitleStyle(MyTitle.TitleStyle.RIGHT_ICON_L);
    title.setOnLeftActionClickListener(new MyTitle.OnLeftActionClickListener() {
        @Override
        public void onClick() {
            finish();
        }
    });

    actionListener = new PopActionListener() {
        @Override
        public void onAction(String action) {
            switch (action) {
            case "?":
                Toast.makeText(KnowledgeMainActivity.this, "?", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(KnowledgeMainActivity.this, RecentViewKnowledgeActivity.class));
                break;
            case "":
                Toast.makeText(KnowledgeMainActivity.this, "", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(KnowledgeMainActivity.this, RecentUploadActivity.class));
                break;
            case "":
                Toast.makeText(KnowledgeMainActivity.this, "", Toast.LENGTH_SHORT).show();
                startActivity(new Intent(KnowledgeMainActivity.this, DownloadRankActivity.class));
                break;
            default:
                break;
            }
        }

        @Override
        public void onDismiss() {

        }
    };

    title.setOnRightActionClickListener(new MyTitle.OnRightActionClickListener() {
        @Override
        public void onRightLClick() {
            startActivity(new Intent(KnowledgeMainActivity.this, FullSearchActivity.class));

        }

        @Override
        public void onRightRClick() {
            PopActionUtil popActionUtil = PopActionUtil.getInstance(KnowledgeMainActivity.this);
            popActionUtil.setActions(new String[] { "?", "", "" });
            PopupWindow popupWindow = popActionUtil.getSimpleTxtPopActionMenu();
            popupWindow.showAtLocation(title.getRootView(), Gravity.TOP | Gravity.END, 10, 100);

            popActionUtil.setActionListener(actionListener);
        }
    });
}

From source file:com.knurld.dropboxdemo.KnurldActivity.java

public PopupWindow showLoadingPopup(View view) {
    View spinnerView = LayoutInflater.from((Activity) context).inflate(R.layout.loading_popup, null);
    ProgressBar progressBar = (ProgressBar) spinnerView.findViewById(R.id.speakProgress);
    progressBar.getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);

    PopupWindow popupWindow = new PopupWindow(spinnerView, 500, 500);
    popupWindow.setFocusable(true);//from www. j  a v  a  2  s.c  om
    popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
    return popupWindow;
}

From source file:com.knurld.dropboxdemo.KnurldActivity.java

public void showInstructions(View view) {
    Activity parent = (Activity) context;
    View spinnerView = LayoutInflater.from(parent).inflate(R.layout.instructions_popup, null);

    TextView textView = (TextView) spinnerView.findViewById(R.id.phraseText);
    textView.setText("Press record to begin recording enrollment");

    PopupWindow popupWindow = new PopupWindow(spinnerView, 500, 500);
    popupWindow.setFocusable(true);//ww w. ja  v  a  2 s  .c o m
    popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);

    final PopupWindow finalPopupWindow = popupWindow;
    new android.os.Handler().postDelayed(new Runnable() {
        public void run() {
            finalPopupWindow.dismiss();
        }
    }, 3000);

}

From source file:com.knurld.dropboxdemo.KnurldActivity.java

public void showMessage(View view, String message) {
    Activity parent = (Activity) context;
    View spinnerView = LayoutInflater.from(parent).inflate(R.layout.instructions_popup, null);

    TextView textView = (TextView) spinnerView.findViewById(R.id.phraseText);
    textView.setText(message);/*  w  w w.  j av  a2  s. c om*/

    PopupWindow popupWindow = new PopupWindow(spinnerView, 500, 500);
    popupWindow.setFocusable(true);
    popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);

    final PopupWindow finalPopupWindow = popupWindow;
    new android.os.Handler().postDelayed(new Runnable() {
        public void run() {
            finalPopupWindow.dismiss();
        }
    }, 3000);

}

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  a2 s. co 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);/*from w w w .  j  av  a2 s. co  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());

}