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

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

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

PopupWindow.setOutsideTouchable介绍

暂无

代码示例

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

/**
 * 点击popupwindow范围以外的地方时隐藏
 *
 * @param popupWindow
 */
public static void openOutsideTouchable(PopupWindow popupWindow) {
  popupWindow.setBackgroundDrawable(new BitmapDrawable());
  popupWindow.setOutsideTouchable(true);
}

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

PopupWindow pw;
LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.weight_popup, (ViewGroup)findViewById(R.id.linlay_weight_popup));
pw = new PopupWindow(layout,LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT, true);
pw.setBackgroundDrawable(new BitmapDrawable());
pw.setOutsideTouchable(true);
pw.showAsDropDown(btnSelectWeight);

代码示例来源: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: jeasonlzy/NineGridView

@OnClick(R.id.more)
public void more(View view) {
  View popupView = mInflater.inflate(R.layout.popup_reply, null);
  popupView.findViewById(R.id.favour).setOnClickListener(this);
  popupView.findViewById(R.id.comment).setOnClickListener(this);
  window = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  window.setOutsideTouchable(true);
  window.setFocusable(true);
  window.setAnimationStyle(R.style.popup_more_anim);
  window.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
  popupView.measure(0, 0);
  int xoff = -popupView.getMeasuredWidth();
  int yoff = -(popupView.getMeasuredHeight() + view.getHeight()) / 2;
  window.showAsDropDown(view, xoff, yoff);
}

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

/**
 * 最核心的pupupwindow创建方法
 *
 * @param contentView popupwindow要显示的视图
 * @param width       popupwindow的宽度
 * @param height      popupwindow的高度
 * @return
 */
@NonNull
private static PopupWindow getPopupWindow(View contentView, int width, int height) {
  PopupWindow popupWindow = new PopupWindow(contentView, width, height, true);
  popupWindow.setOutsideTouchable(false);
  openOutsideTouchable(popupWindow);
  return popupWindow;
}

代码示例来源: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: pili-engineering/PLDroidPlayer

private void initFloatingWindow() {
  mWindow = new PopupWindow(mContext);
  mWindow.setFocusable(false);
  mWindow.setBackgroundDrawable(null);
  mWindow.setOutsideTouchable(true);
  mAnimStyle = android.R.style.Animation;
}

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

private void initFloatingWindow() {
  mWindow = new PopupWindow(mContext);
  mWindow.setFocusable(false);
  mWindow.setBackgroundDrawable(null);
  mWindow.setOutsideTouchable(true);
  mAnimStyle = android.R.style.Animation;
}

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

absoluteLayout.setBackgroundDrawable(null);
mPopup = new PopupWindow(absoluteLayout);
mPopup.setOutsideTouchable(false);
mPopup.setTouchable(false);
mPopup.setFocusable(false);

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

_p.setTouchable(true);
_p.setFocusable(true);
_p.setOutsideTouchable(true);
_p.showAsDropDown(view);

代码示例来源:origin: jeasonlzy/NineGridView

View editView = mInflater.inflate(R.layout.replay_input, null);
editWindow = new PopupWindow(editView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
editWindow.setOutsideTouchable(true);
editWindow.setFocusable(true);
editWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));

代码示例来源: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.setOutsideTouchable(true);
popupWindow.setFocusable(true);

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

private void initCirclePop() {
  View view = LayoutInflater.from(this).inflate(R.layout.layout_circle_comment, null);
  mCiclePop = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  mCiclePop.setAnimationStyle(R.style.RightPopAnim);
  mCiclePop.setFocusable(true);
  mCiclePop.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  mCiclePop.setOutsideTouchable(true);
}

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

private void initQQPop() {
  View view = LayoutInflater.from(this).inflate(R.layout.layout_right_pop, null);
  mQQPop = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  mQQPop.setAnimationStyle(R.style.RightTopPopAnim);
  mQQPop.setFocusable(true);
  mQQPop.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  mQQPop.setOutsideTouchable(true);
}

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

private void initWeiboPop() {
    View view = LayoutInflater.from(this).inflate(R.layout.layout_center_pop, null);
    mWeiboPop = new PopupWindow(view, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    mWeiboPop.setAnimationStyle(R.style.TopPopAnim);
    mWeiboPop.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    mWeiboPop.setFocusable(true);
    mWeiboPop.setOutsideTouchable(false);
  }
}

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

private void initFloatingWindow() {
  mWindow = new PopupWindow(mContext);
  mWindow.setFocusable(false);
  mWindow.setBackgroundDrawable(null);
  mWindow.setOutsideTouchable(true);
  mAnimStyle = android.R.style.Animation;
}

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

private void initFloatingWindow() {
  mWindow = new PopupWindow(mContext);
  mWindow.setFocusable(false);
  mWindow.setBackgroundDrawable(null);
  mWindow.setOutsideTouchable(true);
  mAnimStyle = android.R.style.Animation;
}

代码示例来源:origin: willowtreeapps/Hyperion-Android

private PopupWindow createDetailWindowForView(View view) {
  final Context context = getContext();
  final int width = (int) (getMeasuredWidth() * (4f / 5));
  final int height = getMeasuredHeight() / 2;
  final AttributeDetailView detailView = new AttributeDetailView(context);
  detailView.setTarget(view);
  PopupWindow popupWindow = new PopupWindow(detailView, width, height);
  popupWindow.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(context, R.color.ha_popup_background)));
  popupWindow.setOutsideTouchable(true);
  popupWindow.setFocusable(true);
  return popupWindow;
}

代码示例来源:origin: pinguo-zhouwei/CustomPopwindow

private void test(){
  LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View contentview = inflater.inflate(R.layout.pop_layout1, null);
  final PopupWindow popupWindow = new PopupWindow(contentview, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  //popupWindow
  popupWindow.setFocusable(true);
  popupWindow.setOutsideTouchable(false);
  popupWindow.setBackgroundDrawable(null);
  popupWindow.getContentView().setFocusable(true); // 这个很重要
  popupWindow.getContentView().setFocusableInTouchMode(true);
  popupWindow.getContentView().setOnKeyListener(new View.OnKeyListener() {
    @Override
    public boolean onKey(View v, int keyCode, KeyEvent event) {
      if (keyCode == KeyEvent.KEYCODE_BACK) {
        popupWindow.dismiss();
        return true;
      }
      return false;
    }
  });
  popupWindow.showAsDropDown(mButton1, 0, 10);
}

相关文章