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

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

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

PopupWindow.setFocusable介绍

暂无

代码示例

代码示例来源: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: 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: stackoverflow.com

_p.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
_p.setTouchable(true);
_p.setFocusable(true);
_p.setOutsideTouchable(true);
_p.showAsDropDown(view);

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

mPopup.setOutsideTouchable(false);
mPopup.setTouchable(false);
mPopup.setFocusable(false);

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

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.setContentView(listView);
popupWindow.setOutsideTouchable(true);
popupWindow.setFocusable(true);

代码示例来源: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: 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 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: 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: 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: 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.setFocusable(true);
WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
float width = (wm.getDefaultDisplay().getWidth() * 2) / 3;

代码示例来源: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);
}

相关文章