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

The following examples show how to use android.widget.PopupWindow#setBackgroundDrawable() . 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: 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 2
Source File: ImagePickerFloderPop.java    From FamilyChat with Apache License 2.0 6 votes vote down vote up
public ImagePickerFloderPop(Activity context, ImageFloderBean curFloder, ImagePickerGridPresenter presenter)
{
    this.mContext = context;
    this.mCurFloder = curFloder;
    this.mPresenter = presenter;
    this.mAllFloderList = mPresenter.getAllFloderList();

    mLayout = LayoutInflater.from(context).inflate(R.layout.layout_imagepicker_floder_pop, null);
    mPop = new PopupWindow(mLayout, RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT, true);
    mPop.setBackgroundDrawable(new BitmapDrawable());// 响应返回键必须的语句。
    mPop.setFocusable(true);//设置pop可获取焦点
    mPop.setAnimationStyle(R.style.FloderPopAnimStyle);//设置显示、消失动画
    mPop.setOutsideTouchable(true);//设置点击外部可关闭pop
    mPop.setOnDismissListener(this);

    mListView = (ListView) mLayout.findViewById(R.id.lv_floderpop);
    ImagePickerFloderAdapter adapter = new ImagePickerFloderAdapter(context, mAllFloderList, curFloder);
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(this);

    mLayout.findViewById(R.id.view_floderpop_bg).setOnClickListener(this);
}
 
Example 3
Source File: CityPicker.java    From VersatileRecyclerView with Apache License 2.0 6 votes vote down vote up
public CityPicker(Activity context, View parent) {
    mContext = context;
    mParent = parent;
    //初始化选择器
    View pickerView = LayoutInflater.from(context).inflate(R.layout.city_picker, null);
    mProvinceWheel = (WheelRecyclerView) pickerView.findViewById(R.id.wheel_province);
    mCityWheel = (WheelRecyclerView) pickerView.findViewById(R.id.wheel_city);
    mCountyWheel = (WheelRecyclerView) pickerView.findViewById(R.id.wheel_county);
    pickerView.findViewById(R.id.tv_exit).setOnClickListener(this);
    pickerView.findViewById(R.id.tv_ok).setOnClickListener(this);

    mPickerWindow = new PopupWindow(pickerView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
    mPickerWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    mPickerWindow.setFocusable(true);
    mPickerWindow.setAnimationStyle(R.style.CityPickerAnim);
    mPickerWindow.setOnDismissListener(this);

    initData();
}
 
Example 4
Source File: PopshowAtLocationActivity.java    From AndroidSamples with Apache License 2.0 6 votes vote down vote up
private void showPopupWindow() {
    View contentView = LayoutInflater.from(PopshowAtLocationActivity.this).inflate(R.layout.show_at_location_activity_popup, null);

    mPopWindow = new PopupWindow(contentView,
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);

    mPopWindow.setBackgroundDrawable(new BitmapDrawable());
    mPopWindow.setOutsideTouchable(true);

    TextView tv1 = contentView.findViewById(R.id.pop_computer);
    TextView tv2 = contentView.findViewById(R.id.pop_financial);
    TextView tv3 = contentView.findViewById(R.id.pop_manage);
    tv1.setOnClickListener(this);
    tv2.setOnClickListener(this);
    tv3.setOnClickListener(this);

    View rootview = LayoutInflater.from(PopshowAtLocationActivity.this).inflate(R.layout.show_at_location_activity, null);
    mPopWindow.showAtLocation(rootview, Gravity.BOTTOM, 0, 0);
}
 
Example 5
Source File: ChooseSetPopupWindow.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
private void initView() {
    View contentView = LayoutInflater.from(mContext).inflate(R.layout.popup_choose_set, null);
    contentView.findViewById(R.id.ll_shade).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
    mChooseWindow = new PopupWindow(contentView, -1, -1);
    //点击空白处的时候PopupWindow会消失
    mChooseWindow.setFocusable(true);
    mChooseWindow.setTouchable(true);
    mChooseWindow.setOutsideTouchable(true);
    mChooseWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    // mChooseWindow.setAnimationStyle(R.style.popupAnim);

    //初始化集数列表
    RecyclerView rvChooseSet = (RecyclerView) contentView.findViewById(R.id.rv_choose_set);
    rvChooseSet.setHasFixedSize(true);
    rvChooseSet.setLayoutManager(new GridLayoutManager(mContext, 4));
    rvChooseSet.setAdapter(new ChooseSetAdapter());
}
 
Example 6
Source File: AudioDelayPopup.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
public AudioDelayPopup(Context context, View anchor, ValueChangedListener<Long> listener) {
    LayoutInflater inflater = LayoutInflater.from(context);
    View layout = inflater.inflate(R.layout.audio_delay_popup, null);

    int width = Utils.convertDpToPixel(TvApp.getApplication(), 240);
    int height = Utils.convertDpToPixel(TvApp.getApplication(), 130);

    mPopup = new PopupWindow(layout, width, height);
    mPopup.setFocusable(true);
    mPopup.setOutsideTouchable(true);
    mPopup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); // necessary for popup to dismiss

    mAnchor = anchor;

    mDelaySpinner = layout.findViewById(R.id.numberSpinner);
    mDelaySpinner.setOnChangeListener(listener);
}
 
Example 7
Source File: SelectRemindCyclePopup.java    From Android-AlarmManagerClock with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public SelectRemindCyclePopup(Context context) {
    mContext = context;
    mPopupWindow = new PopupWindow(context);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
    mPopupWindow.setWidth(WindowManager.LayoutParams.FILL_PARENT);
    mPopupWindow.setHeight(WindowManager.LayoutParams.FILL_PARENT);
    mPopupWindow.setTouchable(true);
    mPopupWindow.setFocusable(true);
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setAnimationStyle(R.style.AnimBottom);
    mPopupWindow.setContentView(initViews());
    mPopupWindow.getContentView().setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            mPopupWindow.setFocusable(false);
            // mPopupWindow.dismiss();
            return true;
        }
    });

}
 
Example 8
Source File: MediaController.java    From react-native-android-vitamio with MIT License 5 votes vote down vote up
private void initFloatingWindow() {
  mWindow = new PopupWindow(mContext);
  mWindow.setFocusable(false);
  mWindow.setBackgroundDrawable(null);
  mWindow.setOutsideTouchable(true);
  mAnimStyle = android.R.style.Animation;
}
 
Example 9
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 10
Source File: LuntanToStateActivity.java    From xmpp with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化popupwindow
 */
private void initialPopups() {
    popImageView = new ImageView(this);
    // popImageView.setPadding(50, 50, 50, 50);
    popupWindow = new PopupWindow(popImageView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    popupWindow.setBackgroundDrawable(new ColorDrawable(0xb0000000));

}
 
Example 11
Source File: MediaCatalogPopWindow.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private void init() {
	View view = LayoutInflater.from(mContext).inflate(
			R.layout.zg_widget_pop_media_catalog, null);
	ListView listView = (ListView) view.findViewById(R.id.listview);
	mPopupWindow = new PopupWindow(view, LayoutParams.MATCH_PARENT,
			LayoutParams.WRAP_CONTENT);
	mAdapter = new MediaCatalogAdapter(mContext, mMediaType);
	mAdapter.setFiles(mCatalogs);
	listView.setAdapter(mAdapter);
	listView.setOnItemClickListener(this);
	mPopupWindow.setFocusable(true);
	mPopupWindow.setOutsideTouchable(true);
	mPopupWindow.setBackgroundDrawable(new ColorDrawable(0));
}
 
Example 12
Source File: OrderFragment.java    From shinny-futures-android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * date: 2019/4/17
 * author: chenli
 * description: 构造一个撤单的PopupWindow
 */
private void initPopUp(final View view, final OrderEntity orderEntity) {
    final View popUpView = View.inflate(getActivity(), R.layout.popup_fragment_order, null);
    final PopupWindow popWindow = new PopupWindow(popUpView,
            ViewGroup.LayoutParams.MATCH_PARENT, ScreenUtils.dp2px(getActivity(), 42), true);
    //设置动画,淡入淡出
    popWindow.setAnimationStyle(R.style.anim_menu_quote);
    //点击空白处popupWindow消失
    popWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));
    TextView cancel = popUpView.findViewById(R.id.cancel_order);
    //设置popupWindow显示的位置,参数依次是参照View,x轴的偏移量,y轴的偏移量
    DisplayMetrics outMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
    popWindow.showAsDropDown(view, outMetrics.widthPixels / 4 * 3, 0);
    final String order_id = orderEntity.getOrder_id();
    cancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mIsShowCancelPop) {
                String instrument_id = orderEntity.getExchange_id() + "." + orderEntity.getInstrument_id();
                String ins_name = instrument_id;
                SearchEntity searchEntity = LatestFileManager.getSearchEntities().get(instrument_id);
                if (searchEntity != null) ins_name = searchEntity.getInstrumentName();
                String direction_title = ((TextView) view.findViewById(R.id.order_offset)).getText().toString();
                String volume = orderEntity.getVolume_left();
                String price = ((TextView) view.findViewById(R.id.order_price)).getText().toString();
                initDialog(order_id, ins_name, direction_title, volume, price);
                popWindow.dismiss();
            } else {
                BaseApplication.getmTDWebSocket().sendReqCancelOrder(order_id);
                popWindow.dismiss();
            }
        }
    });
}
 
Example 13
Source File: S.java    From BaldPhone with Apache License 2.0 5 votes vote down vote up
public static void showDropDownPopup(BaldActivity baldActivity, int windowsWidth, DropDownRecyclerViewAdapter.DropDownListener dropDownListener, View view) {
    final RelativeLayout dropDownContainer = (RelativeLayout) LayoutInflater.from(baldActivity).inflate(R.layout.drop_down_recycler_view, null, false);
    final RecyclerView recyclerView = dropDownContainer.findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new LinearLayoutManager(baldActivity) {
        @Override
        public boolean canScrollVertically() {
            return false;
        }
    });
    final PopupWindow popupWindow = new PopupWindow(dropDownContainer, (int) (windowsWidth / 1.3),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 82 * dropDownListener.size(), baldActivity.getResources().getDisplayMetrics()), true);
    recyclerView.addItemDecoration(
            new HorizontalDividerItemDecoration.Builder(baldActivity)
                    .drawable(R.drawable.settings_divider)
                    .build()
    );

    recyclerView.setAdapter(new DropDownRecyclerViewAdapter(baldActivity, popupWindow, dropDownListener));

    final ViewGroup root = (ViewGroup) baldActivity.getWindow().getDecorView().getRootView();
    if (root == null) throw new AssertionError();
    popupWindow.setOnDismissListener(() -> {
        S.clearDim(root);
        dropDownListener.onDismiss();
    });
    popupWindow.setBackgroundDrawable(baldActivity.getDrawable(R.drawable.empty));
    popupWindow.showAsDropDown(view);
    baldActivity.autoDismiss(popupWindow);
    S.applyDim(root);
}
 
Example 14
Source File: CategoryTopicRowViewBinder.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
public static void showPopup(View v) {
    final Context c = v.getContext();
    LayoutInflater inflater = LayoutInflater.from(c);
    TextView contentView = (TextView) inflater.inflate(R.layout.participant_popup_item, null);
    contentView.setText(v.getTag(R.id.poster_name).toString());
    PopupWindow popup = new PopupWindow(c);
    popup.setContentView(contentView);
    popup.setOutsideTouchable(true);
    popup.setWindowLayoutMode(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    popup.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.poster_popup_bg));
    popup.showAsDropDown(v);
}
 
Example 15
Source File: MediaController.java    From video-player with MIT License 5 votes vote down vote up
private void initFloatingWindow() {
  mWindow = new PopupWindow(mContext);
  mWindow.setFocusable(false);
  mWindow.setBackgroundDrawable(null);
  mWindow.setOutsideTouchable(true);
  mAnimStyle = android.R.style.Animation;
}
 
Example 16
Source File: CustomKeyboardView.java    From FirefoxReality with Mozilla Public License 2.0 4 votes vote down vote up
public CustomKeyboardView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    LayoutInflater inflate =
            (LayoutInflater) context
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    int previewLayout = 0;
    int keyTextSize = 0;
    mKeyBackground = context.getDrawable(R.drawable.keyboard_key_background);
    mKeyCapStartBackground = context.getDrawable(R.drawable.keyboard_key_background);
    mVerticalCorrection = 0;
    previewLayout = 0;
    mPreviewOffset = 0;
    mPreviewHeight = 80;
    mKeyTextSize = context.getResources().getDimensionPixelSize(R.dimen.keyboard_key_text_size);
    mKeyTextColor = 0xFFFFFFFF;
    mLabelTextSize = context.getResources().getDimensionPixelSize(R.dimen.keyboard_key_longtext_size);
    mPopupLayout = R.layout.keyboard;
    mShadowColor = 0;
    mShadowRadius = 0;
    mBackgroundDimAmount = 0.5f;
    clearHover();

    mPreviewPopup = new PopupWindow(context);
    if (previewLayout != 0) {
        mPreviewText = (TextView) inflate.inflate(previewLayout, null);
        mPreviewTextSizeLarge = (int) mPreviewText.getTextSize();
        mPreviewPopup.setContentView(mPreviewText);
        mPreviewPopup.setBackgroundDrawable(null);
    } else {
        mShowPreview = false;
    }

    mPreviewPopup.setTouchable(false);

    mPopupKeyboard = new PopupWindow(context);
    mPopupKeyboard.setBackgroundDrawable(null);
    //mPopupKeyboard.setClippingEnabled(false);

    mPopupParent = this;
    //mPredicting = true;

    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setTextSize(keyTextSize);
    mPaint.setTextAlign(Align.CENTER);
    mPaint.setAlpha(255);
    mPaint.setTypeface(Typeface.create("sans-serif",Typeface.NORMAL));

    mPadding = new Rect(0, 0, 0, 0);
    mMiniKeyboardCache = new HashMap<>();
    mKeyBackground.getPadding(mPadding);
    mKeyboardHoveredPadding = getResources().getDimensionPixelSize(R.dimen.keyboard_key_hovered_padding);
    mKeyboardPressedPadding = getResources().getDimensionPixelSize(R.dimen.keyboard_key_pressed_padding);

    mSwipeThreshold = (int) (500 * getResources().getDisplayMetrics().density);
    mDisambiguateSwipe = false;

    mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);

    resetMultiTap();

    mForegroundColor = context.getColor(R.color.asphalt);
    mSelectedForegroundColor = context.getColor(R.color.fog);
}
 
Example 17
Source File: CandidateView.java    From hackerskeyboard with Apache License 2.0 4 votes vote down vote up
/**
 * Construct a CandidateView for showing suggested words for completion.
 * @param context
 * @param attrs
 */
public CandidateView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mSelectionHighlight = context.getResources().getDrawable(
            R.drawable.list_selector_background_pressed);

    LayoutInflater inflate =
        (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Resources res = context.getResources();
    mPreviewPopup = new PopupWindow(context);
    mPreviewText = (TextView) inflate.inflate(R.layout.candidate_preview, null);
    mPreviewPopup.setWindowLayoutMode(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    mPreviewPopup.setContentView(mPreviewText);
    mPreviewPopup.setBackgroundDrawable(null);
    mPreviewPopup.setAnimationStyle(R.style.KeyPreviewAnimation);
    // Enable clipping for Android P, keep disabled for older versions.
    boolean clippingEnabled = (Build.VERSION.SDK_INT >= 28 /* Build.VERSION_CODES.P */);
    mPreviewPopup.setClippingEnabled(clippingEnabled);
    mColorNormal = res.getColor(R.color.candidate_normal);
    mColorRecommended = res.getColor(R.color.candidate_recommended);
    mColorOther = res.getColor(R.color.candidate_other);
    mDivider = res.getDrawable(R.drawable.keyboard_suggest_strip_divider);
    mAddToDictionaryHint = res.getString(R.string.hint_add_to_dictionary);

    mPaint = new Paint();
    mPaint.setColor(mColorNormal);
    mPaint.setAntiAlias(true);
    mPaint.setTextSize(mPreviewText.getTextSize() * LatinIME.sKeyboardSettings.candidateScalePref);
    mPaint.setStrokeWidth(0);
    mPaint.setTextAlign(Align.CENTER);
    mDescent = (int) mPaint.descent();
    mMinTouchableWidth = (int)res.getDimension(R.dimen.candidate_min_touchable_width);
    
    mGestureDetector = new GestureDetector(
            new CandidateStripGestureListener(mMinTouchableWidth));
    setWillNotDraw(false);
    setHorizontalScrollBarEnabled(false);
    setVerticalScrollBarEnabled(false);
    scrollTo(0, getScrollY());
}
 
Example 18
Source File: MediaController.java    From BambooPlayer with Apache License 2.0 4 votes vote down vote up
private void initFloatingWindow() {
	mWindow = new PopupWindow(mContext);
	mWindow.setFocusable(true);
	mWindow.setBackgroundDrawable(null);
	mWindow.setOutsideTouchable(true);
}
 
Example 19
Source File: StandOutWindow.java    From Roundr with Apache License 2.0 4 votes vote down vote up
/**
 * You probably want to leave this method alone and implement
 * {@link #getDropDownItems(int)} instead. Only implement this method if you
 * want more control over the drop down menu.
 * 
 * <p>
 * Implement this method to set a custom drop down menu when the user clicks
 * on the icon of the window corresponding to the id. The icon is only shown
 * when {@link StandOutFlags#FLAG_DECORATION_SYSTEM} is set.
 * 
 * @param id
 *            The id of the window.
 * @return The drop down menu to be anchored to the icon, or null to have no
 *         dropdown menu.
 */
public PopupWindow getDropDown(final int id) {
	final List<DropDownListItem> items;

	List<DropDownListItem> dropDownListItems = getDropDownItems(id);
	if (dropDownListItems != null) {
		items = dropDownListItems;
	} else {
		items = new ArrayList<StandOutWindow.DropDownListItem>();
	}

	// add default drop down items
	items.add(new DropDownListItem(android.R.drawable.ic_menu_close_clear_cancel, "Quit " + getAppName(), new Runnable() {

		@Override
		public void run() {
			closeAll();
		}
	}));

	// turn item list into views in PopupWindow
	LinearLayout list = new LinearLayout(this);
	list.setOrientation(LinearLayout.VERTICAL);

	ScrollView scroller = new ScrollView(this);
	scroller.addView(list);

	final PopupWindow dropDown = new PopupWindow(scroller, StandOutLayoutParams.WRAP_CONTENT, StandOutLayoutParams.WRAP_CONTENT, true);

	for (final DropDownListItem item : items) {
		ViewGroup listItem = (ViewGroup) mLayoutInflater.inflate(R.layout.drop_down_list_item, null);
		list.addView(listItem);

		ImageView icon = (ImageView) listItem.findViewById(R.id.icon);
		icon.setImageResource(item.icon);

		TextView description = (TextView) listItem.findViewById(R.id.description);
		description.setText(item.description);

		listItem.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				item.action.run();
				dropDown.dismiss();
			}
		});
	}

	Drawable background = getResources().getDrawable(android.R.drawable.editbox_dropdown_dark_frame);
	dropDown.setBackgroundDrawable(background);
	return dropDown;
}
 
Example 20
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;
}