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

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

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

PopupWindow.setContentView介绍

暂无

代码示例

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

tv.setText("Hi this is a sample text for popup window");
layout.addView(tv, params);
popUp.setContentView(layout);

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

containerLayout.setOrientation(LinearLayout.VERTICAL);
containerLayout.addView(tvMsg, layoutParams);
popUpWindow.setContentView(containerLayout);
mainLayout.addView(btnClickHere, layoutParams);
setContentView(mainLayout);

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

_p.setContentView(_lv);
_p.setWidth(getWidth());
_p.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);

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

/**
 * 设置VideoView
 */
public void setAnchorView(View view) {
  mAnchor = view;
  if (!mFromXml) {
    removeAllViews();
    mRoot = makeControllerView();
    mWindow.setContentView(mRoot);
    mWindow.setWidth(LayoutParams.MATCH_PARENT);
    mWindow.setHeight(LayoutParams.WRAP_CONTENT);
  }
  initControllerView(mRoot);
}

代码示例来源:origin: pili-engineering/PLDroidPlayer

/**
 * Set the view that acts as the anchor for the control view.
 *
 * - This can for example be a VideoView, or your Activity's main view.
 * - AudioPlayer has no anchor view, so the view parameter will be null.
 *
 * @param view
 * The view to which to anchor the controller when it is visible.
 */
@Override
public void setAnchorView(View view) {
  mAnchor = view;
  if (mAnchor == null) {
    sDefaultTimeout = 0; // show forever
  }
  if (!mFromXml) {
    removeAllViews();
    mRoot = makeControllerView();
    mWindow.setContentView(mRoot);
    mWindow.setWidth(LayoutParams.MATCH_PARENT);
    mWindow.setHeight(LayoutParams.WRAP_CONTENT);
  }
  initControllerView(mRoot);
}

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

clarityPopWindow.setContentView(layout);
clarityPopWindow.showAsDropDown(clarity);
layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

代码示例来源:origin: termux/termux-app

popupWindow.setContentView(null);
popupWindow.dismiss();
popupWindow = null;

代码示例来源:origin: termux/termux-app

void popup(View view, String text) {
  int width = view.getMeasuredWidth();
  int height = view.getMeasuredHeight();
  Button button = new Button(getContext(), null, android.R.attr.buttonBarButtonStyle);
  button.setText(text);
  button.setTextColor(TEXT_COLOR);
  button.setPadding(0, 0, 0, 0);
  button.setMinHeight(0);
  button.setMinWidth(0);
  button.setMinimumWidth(0);
  button.setMinimumHeight(0);
  button.setWidth(width);
  button.setHeight(height);
  button.setBackgroundColor(BUTTON_PRESSED_COLOR);
  popupWindow = new PopupWindow(this);
  popupWindow.setWidth(LayoutParams.WRAP_CONTENT);
  popupWindow.setHeight(LayoutParams.WRAP_CONTENT);
  popupWindow.setContentView(button);
  popupWindow.setOutsideTouchable(true);
  popupWindow.setFocusable(false);
  popupWindow.showAsDropDown(view, 0, -2 * height);
}

代码示例来源:origin: arcadefire/nice-spinner

popupWindow.setContentView(listView);
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);

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

View view = new View(getContext());
view.setLayoutParams(new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
popupWindow.setContentView(view);
popupWindow.setTouchInterceptor((v, event) -> {
  popupWindow.dismiss();

代码示例来源:origin: Bearded-Hen/Android-Bootstrap

private void createDropDown() {
  ScrollView dropdownView = createDropDownView();
  dropdownWindow = new PopupWindow();
  dropdownWindow.setFocusable(true);
  dropdownWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
  if (!isInEditMode()) {
    dropdownWindow.setBackgroundDrawable(DrawableUtils.resolveDrawable(android.R.drawable
                                          .dialog_holo_light_frame, getContext()));
  }
  dropdownWindow.setContentView(dropdownView);
  dropdownWindow.setOnDismissListener(this);
  dropdownWindow.setAnimationStyle(android.R.style.Animation_Activity);
  float longestStringWidth = measureStringWidth(getLongestString(dropdownData))
      + DimenUtils.dpToPixels((baselineItemRightPadding + baselineItemLeftPadding) * bootstrapSize);
  if (longestStringWidth < getMeasuredWidth()) {
    dropdownWindow.setWidth(DimenUtils.dpToPixels(getMeasuredWidth()));
  }
  else {
    dropdownWindow.setWidth((int) longestStringWidth + DimenUtils.dpToPixels(8));
  }
}

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

PopupWindow popupwindow_obj = popupDisplay();
popupwindow_obj.showAsDropDown(clickbtn, -40, 18); // where u want show on view click event popupwindow.showAsDropDown(view, x, y);

public PopupWindow popupDisplay() 
{ 

  final PopupWindow popupWindow = new PopupWindow(this);

  // inflate your layout or dynamically add view
  LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

  View view = inflater.inflate(R.layout.mylayout, null);

  Button item = (Button) view.findViewById(R.id.button1);

  popupWindow.setFocusable(true);
  popupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
  popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
  popupWindow.setContentView(view);

  return popupWindow;
}

代码示例来源:origin: multidots/android-app-common-tasks

popupWindow.setContentView(pList);
popupWindow.showAsDropDown(actionView, 10, 10);

代码示例来源:origin: multidots/android-app-common-tasks

popupWindow.setContentView(pList);
popupWindow.showAsDropDown(actionView, 10, 10);

代码示例来源:origin: zyyoona7/EasyPopup

private void initContentViewAndWH() {
  if (mContentView == null) {
    if (mLayoutId != 0 && mContext != null) {
      mContentView = LayoutInflater.from(mContext).inflate(mLayoutId, null);
    } else {
      throw new IllegalArgumentException("The content view is null,the layoutId=" + mLayoutId + ",context=" + mContext);
    }
  }
  mPopupWindow.setContentView(mContentView);
  if (mWidth > 0 || mWidth == ViewGroup.LayoutParams.WRAP_CONTENT || mWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
    mPopupWindow.setWidth(mWidth);
  } else {
    mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
  }
  if (mHeight > 0 || mHeight == ViewGroup.LayoutParams.WRAP_CONTENT || mHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
    mPopupWindow.setHeight(mHeight);
  } else {
    mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
  }
  //测量contentView大小
  //可能不准
  measureContentView();
  //获取contentView的精准大小
  registerOnGlobalLayoutListener();
  mPopupWindow.setInputMethodMode(mInputMethodMode);
  mPopupWindow.setSoftInputMode(mSoftInputMode);
}

代码示例来源:origin: chat-sdk/chat-sdk-android

imagePopup.setContentView(popupView);
imagePopup.setBackgroundDrawable(new BitmapDrawable());
imagePopup.setOutsideTouchable(true);

代码示例来源:origin: pili-engineering/PLDroidShortVideo

/**
 * Set the view that acts as the anchor for the control view.
 *
 * - This can for example be a VideoView, or your Activity's main view.
 * - AudioPlayer has no anchor view, so the view parameter will be null.
 *
 * @param view
 * The view to which to anchor the controller when it is visible.
 */
@Override
public void setAnchorView(View view) {
  mAnchor = view;
  if (mAnchor == null) {
    sDefaultTimeout = 0; // show forever
  }
  if (!mFromXml) {
    removeAllViews();
    mRoot = makeControllerView();
    mWindow.setContentView(mRoot);
    mWindow.setWidth(FrameLayout.LayoutParams.MATCH_PARENT);
    mWindow.setHeight(FrameLayout.LayoutParams.WRAP_CONTENT);
  }
  initControllerView(mRoot);
}

代码示例来源:origin: curtis2/SuperVideoPlayer

/**
 * Set the view that acts as the anchor for the control view. This can for
 * example be a VideoView, or your Activity's main view.
 *
 * @param view The view to which to anchor the controller when it is visible.
 */
public void setAnchorView(View view) {
  mAnchor = view;
  if (!mFromXml) {
    removeAllViews();
    mRoot = makeControllerView();
    mWindow.setContentView(mRoot);
    mWindow.setWidth(LayoutParams.MATCH_PARENT);
    mWindow.setHeight(LayoutParams.WRAP_CONTENT);
  }
  initControllerView(mRoot);
  initOtherView();
}

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

popupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
popupWindow.setContentView(popupView);

代码示例来源:origin: MasayukiSuda/BubbleLayout

public static PopupWindow create(@NonNull Context context, @NonNull BubbleLayout bubbleLayout) {
  PopupWindow popupWindow = new PopupWindow(context);
  popupWindow.setContentView(bubbleLayout);
  popupWindow.setOutsideTouchable(true);
  popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
  popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
  popupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
  // change background color to transparent
  popupWindow.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.popup_window_transparent));
  return popupWindow;
}

相关文章