Java Code Examples for android.widget.PopupWindow#setSoftInputMode()

The following examples show how to use android.widget.PopupWindow#setSoftInputMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DropPopMenu.java    From AndroidWallet with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
private void create() {
    mPopupWindow = new PopupWindow(mDropPopLayout, LinearLayout.LayoutParams.MATCH_PARENT
            , LinearLayout.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mPopupWindow.setFocusable(true);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
    mPopupWindow.setOnDismissListener(new PopOnDismissListener());

    mDropPopLayout.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            mPopupWindow.dismiss();
            return true;
        }
    });
}
 
Example 2
Source File: CustomPopupWindow.java    From YCDialog with Apache License 2.0 6 votes vote down vote up
private void apply(PopupWindow mPopupWindow) {
    mPopupWindow.setClippingEnabled(this.mClippEnable);
    if(this.mIgnoreCheekPress) {
        mPopupWindow.setIgnoreCheekPress();
    }

    if(this.mInputMode != -1) {
        mPopupWindow.setInputMethodMode(this.mInputMode);
    }

    if(this.mSoftInputMode != -1) {
        mPopupWindow.setSoftInputMode(this.mSoftInputMode);
    }

    if(this.mOnDismissListener != null) {
        mPopupWindow.setOnDismissListener(this.mOnDismissListener);
    }

    if(this.mOnTouchListener != null) {
        mPopupWindow.setTouchInterceptor(this.mOnTouchListener);
    }

    mPopupWindow.setTouchable(this.mTouchable);
}
 
Example 3
Source File: PopupActivity.java    From ImmersionBar with Apache License 2.0 6 votes vote down vote up
/**
 * 弹出popupWindow
 * Show popup.
 *
 * @param gravity        the gravity
 * @param width          the width
 * @param height         the height
 * @param animationStyle the animation style
 */
private void showPopup(int gravity, int width, int height, int animationStyle) {
    mPopupView = LayoutInflater.from(mActivity).inflate(R.layout.popup_demo, null);
    mPopupWindow = new PopupWindow(mPopupView, width, height);
    //以下属性响应空白处消失和实体按键返回消失popup
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setFocusable(true);
    mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    //沉浸式模式下,以下两个属性并不起作用
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    //重点,此方法可以让布局延伸到状态栏和导航栏
    mPopupWindow.setClippingEnabled(false);
    //设置动画
    mPopupWindow.setAnimationStyle(animationStyle);
    //弹出
    mPopupWindow.showAtLocation(getWindow().getDecorView(), gravity, 0, 0);
    //弹出后背景alpha值
    backgroundAlpha(0.5f);
    //消失后恢复背景alpha值
    mPopupWindow.setOnDismissListener(() -> backgroundAlpha(1f));
    //适配弹出popup后布局被状态栏和导航栏遮挡问题
    updatePopupView();
}
 
Example 4
Source File: CustomPopWindow.java    From LLApp with Apache License 2.0 6 votes vote down vote up
/**
 * 添加一些属性设置
 * @param popupWindow
 */
private void apply(PopupWindow popupWindow){
    popupWindow.setClippingEnabled(mClippEnable);
    if(mIgnoreCheekPress){
        popupWindow.setIgnoreCheekPress();
    }
    if(mInputMode!=-1){
        popupWindow.setInputMethodMode(mInputMode);
    }
    if(mSoftInputMode!=-1){
        popupWindow.setSoftInputMode(mSoftInputMode);
    }
    if(mOnDismissListener!=null){
        popupWindow.setOnDismissListener(mOnDismissListener);
    }
    if(mOnTouchListener!=null){
        popupWindow.setTouchInterceptor(mOnTouchListener);
    }
    popupWindow.setTouchable(mTouchable);



}
 
Example 5
Source File: DialogReply.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
private void init() {
    View contentLayout = mInflater.inflate(R.layout.z_dialog_reply, null);
    mLayout_board = contentLayout.findViewById(R.id.layout_board);
    mEt_reply = (EditText) contentLayout.findViewById(R.id.et_reply);
    contentLayout.findViewById(R.id.iv_close).setOnClickListener(this);
    contentLayout.findViewById(R.id.iv_send).setOnClickListener(this);

    mWindow = new PopupWindow(contentLayout, LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    mWindow.setFocusable(true);
    mWindow.setOutsideTouchable(true);
    mWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
            | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    mWindow.setBackgroundDrawable(new ColorDrawable(0));
    mWindow.setAnimationStyle(R.style.AnimUpDown);
}
 
Example 6
Source File: SearchResultPop.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
public SearchResultPop(Context context, final FileListAdapter adapter){

        this.adapter = adapter;

        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

        LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = layoutInflater.inflate(R.layout.search_result_pop, null);

        GridView gridView = (GridView) view.findViewById(R.id.gridView);
        gridView.setAdapter(adapter);
        gridView.requestFocus();
        // EditText 与 popwindow焦点冲突
//        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
//                popupWindow.setFocusable(true);
//                listener.onClick((FileInfo)adapter.getItem(arg2), arg2);
//            }
//        });

        popupWindow = new PopupWindow(view,
                windowManager.getDefaultDisplay().getWidth(),
                windowManager.getDefaultDisplay().getHeight()*4/5);

        // 使其聚集
        //popupWindow.setFocusable(true);
        // 解决popupWindow挡住虚拟键盘
        popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
        popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
        // 设置允许在外点击消失
        popupWindow.setOutsideTouchable(false);
        // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景
        popupWindow.setBackgroundDrawable(new BitmapDrawable());
    }
 
Example 7
Source File: WXMask.java    From incubator-weex-playground with Apache License 2.0 4 votes vote down vote up
@Override
protected View initComponentHostView(@NonNull Context context) {

  mContainerView = new WXMaskView(context);
  mPopupWindow = new PopupWindow(context);
  mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
    mPopupWindow.setAttachedInDecor(true);
  }

  //setClippingEnabled(false) will cause INPUT_ADJUST_PAN invalid.
  //mPopupWindow.setClippingEnabled(false);

  mPopupWindow.setContentView(mContainerView);
  mPopupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
  mPopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
  mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN |
      WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
  mPopupWindow.setFocusable(true);

  mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
    @Override
    public void onDismiss() {
      fireVisibleChangedEvent(false);
    }
  });

  int y = 0;
  int statusBarHeight = 0;
  int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
  if (resourceId > 0) {
    statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
    y = statusBarHeight;
  }

  mPopupWindow.showAtLocation(((Activity) context).getWindow().getDecorView(),
      Gravity.TOP | Gravity.START,
      0,
      y);
  fireVisibleChangedEvent(true);

  return mContainerView;
}
 
Example 8
Source File: StarkSpinner.java    From SSForms with GNU General Public License v3.0 4 votes vote down vote up
private void init() {
    setupColors();
    setupList();
    mSearchEditText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    mStartSearchImageView.setOnClickListener(this);
    mDoneSearchImageView.setOnClickListener(this);
    mSearchEditText.addTextChangedListener(mTextWatcher);

    mPopupWindow = new PopupWindow(mContext);
    mPopupWindow.setContentView(mSpinnerListContainer);
    mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            hideEdit();
        }
    });
    mPopupWindow.setFocusable(false);
    mPopupWindow.setElevation(DefaultElevation);
    mPopupWindow.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.spinner_drawable));

    mSpinnerListView.setOnItemClickListener(mOnItemSelectedListener);
    if (mCurrSelectedView == null) {
        if (!TextUtils.isEmpty(mSearchHintText)) {
            mSearchEditText.setHint(mSearchHintText);
        }
        if (!TextUtils.isEmpty(mNoItemsFoundText)) {
            mEmptyTextView.setText(mNoItemsFoundText);
        }
        if (mCurrSelectedView == null && !TextUtils.isEmpty(mRevealEmptyText)) {
            TextView textView = new TextView(mContext);
            textView.setText(mRevealEmptyText);
            mCurrSelectedView = new SelectedView(textView, -1, 0);
            mRevealItem.addView(textView);
        }
    } else {
        mSpinnerListView.performItemClick(mCurrSelectedView.getView(), mCurrSelectedView.getPosition(), mCurrSelectedView.getId());
    }
    clearAnimation();
    clearFocus();
}
 
Example 9
Source File: SearchableSpinner.java    From searchablespinner with Apache License 2.0 4 votes vote down vote up
private void init() {
    setupColors();
    setupList();
    mSearchEditText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    mStartSearchImageView.setOnClickListener(this);
    mDoneSearchImageView.setOnClickListener(this);
    mSearchEditText.addTextChangedListener(mTextWatcher);

    mPopupWindow = new PopupWindow(mContext);
    mPopupWindow.setContentView(mSpinnerListContainer);
    mPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    mPopupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NEEDED);
    mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            hideEdit();
        }
    });
    mPopupWindow.setFocusable(false);
    mPopupWindow.setElevation(DefaultElevation);
    mPopupWindow.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.spinner_drawable));

    mSpinnerListView.setOnItemClickListener(mOnItemSelectedListener);
    if (mCurrSelectedView == null) {
        if (!TextUtils.isEmpty(mSearchHintText)) {
            mSearchEditText.setHint(mSearchHintText);
        }
        if (!TextUtils.isEmpty(mNoItemsFoundText)) {
            mEmptyTextView.setText(mNoItemsFoundText);
        }
        if (mCurrSelectedView == null && !TextUtils.isEmpty(mRevealEmptyText)) {
            TextView textView = new TextView(mContext);
            textView.setText(mRevealEmptyText);
            mCurrSelectedView = new SelectedView(textView, -1, 0);
            mRevealItem.addView(textView);
        }
    } else {
        mSpinnerListView.performItemClick(mCurrSelectedView.getView(), mCurrSelectedView.getPosition(), mCurrSelectedView.getId());
    }
    clearAnimation();
    clearFocus();
}
 
Example 10
Source File: EmojiPopup.java    From hipda with GNU General Public License v2.0 4 votes vote down vote up
private EmojiPopup(final View rootView, final EmojiEditText emojiEditText, @Nullable final RecentEmoji recent) {
    this.context = rootView.getContext();
    this.rootView = rootView;
    this.emojiEditText = emojiEditText;
    this.recentEmoji = recent != null ? recent : new RecentEmojiManager(context);
    this.keyBoardHeight = getPreferences().getInt(PREF_KEYBOARD_HEIGHT, 0);

    popupWindow = new PopupWindow(context);
    popupWindow.setBackgroundDrawable(new BitmapDrawable(context.getResources(), (Bitmap) null)); // To avoid borders & overdraw

    final EmojiView emojiView = new EmojiView(context, new OnEmojiClickedListener() {
        @Override
        public void onEmojiClicked(final Emoji emoji) {
            emojiEditText.input(emoji);
            recentEmoji.addEmoji(emoji);

            if (onEmojiClickedListener != null) {
                onEmojiClickedListener.onEmojiClicked(emoji);
            }
        }
    }, this.recentEmoji);

    emojiView.setOnEmojiBackspaceClickListener(new OnEmojiBackspaceClickListener() {
        @Override
        public void onEmojiBackspaceClicked(final View v) {
            emojiEditText.backspace();

            if (onEmojiBackspaceClickListener != null) {
                onEmojiBackspaceClickListener.onEmojiBackspaceClicked(v);
            }
        }
    });

    popupWindow.setContentView(emojiView);
    popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    popupWindow.setWidth(WindowManager.LayoutParams.MATCH_PARENT);
    popupWindow.setHeight((int) context.getResources().getDimension(R.dimen.emoji_keyboard_height));
    popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            if (onEmojiPopupDismissListener != null) {
                onEmojiPopupDismissListener.onEmojiPopupDismiss();
            }
        }
    });

    setupListener();
}