android.widget.PopupWindow.showAtLocation()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(279)

本文整理了Java中android.widget.PopupWindow.showAtLocation()方法的一些代码示例,展示了PopupWindow.showAtLocation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PopupWindow.showAtLocation()方法的具体详情如下:
包路径:android.widget.PopupWindow
类名称:PopupWindow
方法名:showAtLocation

PopupWindow.showAtLocation介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

LayoutInflater inflater = (LayoutInflater)
   this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
 PopupWindow pw = new PopupWindow(
   inflater.inflate(R.layout.popup_example, null, false), 
   100, 
   100, 
   true);
 // The code below assumes that the root container has an id called 'main'
 pw.showAtLocation(this.findViewById(R.id.main), Gravity.CENTER, 0, 0);

代码示例来源:origin: smuyyh/BookReader

@Override
  public void showAtLocation(View parent, int gravity, int x, int y) {
    lightoff();
    super.showAtLocation(parent, gravity, x, y);
  }
}

代码示例来源:origin: smuyyh/BookReader

@Override
public void showAtLocation(View parent, int gravity, int x, int y) {
  lightoff();
  super.showAtLocation(parent, gravity, x, y);
}

代码示例来源:origin: seven332/EhViewer

@Override
protected void onAttachedToWindow() {
  super.onAttachedToWindow();
  mPopup.showAtLocation(this, Gravity.TOP | Gravity.LEFT, mPopupX, mPopupY);
}

代码示例来源:origin: ZieIony/Carbon

public boolean showImmediate(View anchor) {
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  contentView.measure(View.MeasureSpec.makeMeasureSpec(wm.getDefaultDisplay().getWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
  super.update(wm.getDefaultDisplay().getWidth(), contentView.getMeasuredHeight());
  bubble.setVisibility(View.VISIBLE);
  return true;
}

代码示例来源:origin: ZieIony/Carbon

public boolean show(View anchor) {
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
  contentView.measure(View.MeasureSpec.makeMeasureSpec(wm.getDefaultDisplay().getWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
  super.update(wm.getDefaultDisplay().getWidth(), contentView.getMeasuredHeight());
  bubble.animateVisibility(View.VISIBLE);
  return true;
}

代码示例来源:origin: GitLqr/LQRWeChat

/**
 * 得到指定在某个视图内位置的popupwindow并显示
 *
 * @param contentView popupwindow要显示的视图
 * @param width       popupwindow的宽度
 * @param height      popupwindow的高度
 * @param parentView  参考视图
 * @param gravityType 在参考视图中的相对位置
 * @param xoff        x轴偏移量
 * @param yoff        y轴偏移量
 * @return
 */
public static PopupWindow getPopupWindowAtLocation(View contentView, int width, int height, View parentView, int gravityType, int xoff, int yoff) {
  PopupWindow popupWindow = getPopupWindow(contentView, width, height);
  //在parentView中偏移xoff和yoff
  popupWindow.showAtLocation(parentView,
      gravityType, xoff, yoff);
  return popupWindow;
}

代码示例来源:origin: ZieIony/Carbon

public boolean show(EditText anchor) {
  editText = anchor;
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  update();
  View content = getContentView().findViewById(R.id.carbon_menuContainer);
  content.setVisibility(View.VISIBLE);
  return true;
}

代码示例来源:origin: GitLqr/LQRWeChat

@Override
public void initTipView() {
  View view = View.inflate(SessionActivity.this, R.layout.popup_audio_wi_vo, null);
  mStateIV = (ImageView) view.findViewById(R.id.rc_audio_state_image);
  mStateTV = (TextView) view.findViewById(R.id.rc_audio_state_text);
  mTimerTV = (TextView) view.findViewById(R.id.rc_audio_timer);
  mRecordWindow = new PopupWindow(view, -1, -1);
  mRecordWindow.showAtLocation(mLlRoot, 17, 0, 0);
  mRecordWindow.setFocusable(true);
  mRecordWindow.setOutsideTouchable(false);
  mRecordWindow.setTouchable(false);
}

代码示例来源:origin: ZieIony/Carbon

public boolean show(View anchor) {
  anchorView = anchor;
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  update();
  FrameLayout content = getContentView().findViewById(R.id.carbon_popupContainer);
  content.animateVisibility(View.VISIBLE);
  return true;
}

代码示例来源:origin: ZieIony/Carbon

public boolean showImmediate(View anchor) {
  anchorView = anchor;
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  update();
  FrameLayout content = getContentView().findViewById(R.id.carbon_popupContainer);
  content.setVisibility(View.VISIBLE);
  return true;
}

代码示例来源:origin: ZieIony/Carbon

public boolean show(android.view.View anchor) {
  mAnchorView = anchor;
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  update();
  carbon.widget.FrameLayout content = getContentView().findViewById(R.id.carbon_popupContainer);
  content.animateVisibility(android.view.View.VISIBLE);
  return true;
}

代码示例来源:origin: ZieIony/Carbon

public boolean showImmediate(android.view.View anchor) {
  mAnchorView = anchor;
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  update();
  carbon.widget.FrameLayout content = getContentView().findViewById(R.id.carbon_popupContainer);
  content.setVisibility(android.view.View.VISIBLE);
  return true;
}

代码示例来源:origin: ZieIony/Carbon

public boolean showImmediate(EditText anchor) {
  editText = anchor;
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  update();
  LinearLayout content = getContentView().findViewById(R.id.carbon_menuContainer);
  content.setVisibility(View.VISIBLE);
  return true;
}

代码示例来源:origin: aa112901/remusic

@Override
protected void onPreExecute() {
  super.onPreExecute();
  View view;
  if (popupWindow == null) {
    LayoutInflater layoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = layoutInflater.inflate(R.layout.loading_circle, null);
    popupWindow = new PopupWindow(view, 200, 220);
  }
  popupWindow.setFocusable(true);
  popupWindow.setOutsideTouchable(true);
  // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
  popupWindow.setBackgroundDrawable(new BitmapDrawable());
  popupWindow.showAtLocation(mContext.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
  popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
    @Override
    public void onDismiss() {
      RequestThreadPool.finish();
      cancel(true);
    }
  });
}

代码示例来源:origin: ZieIony/Carbon

public void show() {
  View anchor = context.getWindow().getDecorView().getRootView();
  setContentView(new DebugLayout(context, anchor));
  getContentView().setLayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
  setBackgroundDrawable(new ColorDrawable(context.getResources().getColor(android.R.color.transparent)));
  setTouchable(false);
  setFocusable(false);
  setOutsideTouchable(false);
  setAnimationStyle(0);
  super.showAtLocation(anchor, Gravity.START | Gravity.TOP, 0, 0);
  update(anchor.getWidth(), anchor.getHeight());
  anchor.getViewTreeObserver().addOnPreDrawListener(listener);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

+ mAnchor.getHeight());
mWindow.setAnimationStyle(mAnimStyle);
mWindow.showAtLocation(mAnchor, Gravity.BOTTOM,
    anchorRect.left, 0);

代码示例来源:origin: stackoverflow.com

popUp.showAtLocation(layout, Gravity.BOTTOM, 10, 10);
popUp.update(50, 50, 300, 80);
click = false;

代码示例来源:origin: stackoverflow.com

if (isClicked) {
  isClicked = false;
  popUpWindow.showAtLocation(mainLayout, Gravity.BOTTOM, 10, 10);
  popUpWindow.update(50, 50, 320, 90);
} else {

代码示例来源:origin: robolectric/robolectric

@Test
public void getLatestPopupWindow() {
 PopupWindow pw = new PopupWindow(new LinearLayout(context));
 pw.showAtLocation(new LinearLayout(context), Gravity.CENTER, 0, 0);
 PopupWindow latestPopupWindow = ShadowApplication.getInstance().getLatestPopupWindow();
 assertThat(latestPopupWindow).isSameAs(pw);
}

相关文章