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

The following examples show how to use android.widget.PopupWindow#setAnimationStyle() . 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: TextBubble.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a {@link TextBubble} instance.
 * @param context  Context to draw resources from.
 * @param rootView The {@link View} to use for size calculations and for display.
 * @param stringId The id of the string resource for the text that should be shown.
 * @param accessibilityStringId The id of the string resource of the accessibility text.
 */
public TextBubble(Context context, View rootView, @StringRes int stringId,
        @StringRes int accessibilityStringId) {
    mContext = context;
    mRootView = rootView.getRootView();
    mStringId = stringId;
    mAccessibilityStringId = accessibilityStringId;
    mPopupWindow = new PopupWindow(mContext);
    mDrawable = new ArrowBubbleDrawable(context);
    mHandler = new Handler();

    mPopupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setBackgroundDrawable(mDrawable);
    mPopupWindow.setAnimationStyle(R.style.TextBubbleAnimation);

    mPopupWindow.setTouchInterceptor(this);
    mPopupWindow.setOnDismissListener(mDismissListener);

    mMarginPx = context.getResources().getDimensionPixelSize(R.dimen.text_bubble_margin);

    // Set predefined styles for the TextBubble.
    mDrawable.setBubbleColor(
            ApiCompatibilityUtils.getColor(mContext.getResources(), R.color.google_blue_500));
}
 
Example 2
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 3
Source File: BottomMenu.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
public BottomMenu(Activity context,OnClickListener clickListener) {
    LayoutInflater inflater = LayoutInflater.from(context);
    this.clickListener=clickListener;
    mContext=context;
    mMenuView = inflater.inflate(R.layout.layout_popwindow, null);
    btn_wxLogin = (Button) mMenuView.findViewById(R.id.btn_wxLogin);
    btn_msgCheckLogin = (Button) mMenuView.findViewById(R.id.btn_msgCheckLogin);
    btnCancel = (Button) mMenuView.findViewById(R.id.btn_cancel);
    btnCancel.setOnClickListener(this);
    btn_wxLogin.setOnClickListener(this);
    btn_msgCheckLogin.setOnClickListener(this);
    popupWindow=new PopupWindow(mMenuView,LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT,true);
    popupWindow.setAnimationStyle(R.style.popwin_anim_style);
    ColorDrawable dw = new ColorDrawable(context.getResources().getColor(R.color.white));
    popupWindow.setBackgroundDrawable(dw);
    mMenuView.setOnTouchListener(this);
}
 
Example 4
Source File: LiveProgramDetailPopup.java    From jellyfin-androidtv with GNU General Public License v2.0 6 votes vote down vote up
public LiveProgramDetailPopup(BaseActivity activity, int width, EmptyResponse tuneAction) {
    mActivity = activity;
    mTuneAction = tuneAction;
    LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.program_detail_popup, null);
    mPopup = new PopupWindow(layout, width, NORMAL_HEIGHT);
    mPopup.setFocusable(true);
    mPopup.setOutsideTouchable(true);
    mPopup.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); // necessary for popup to dismiss
    mPopup.setAnimationStyle(R.style.PopupSlideInTop);
    mDTitle = layout.findViewById(R.id.title);
    mDSummary = layout.findViewById(R.id.summary);
    mDRecordInfo = layout.findViewById(R.id.recordLine);
    mDTimeline = layout.findViewById(R.id.timeline);
    mDButtonRow = layout.findViewById(R.id.buttonRow);
    mDInfoRow = layout.findViewById(R.id.infoRow);
    mDSimilarRow = layout.findViewById(R.id.similarRow);
}
 
Example 5
Source File: ProgressHintDelegate.java    From progresshint with Apache License 2.0 6 votes vote down vote up
private void initHintPopup() {
  String popupText = null;
  if (mHintAdapter != null) {
    popupText = mHintAdapter.getHint(mSeekBar, mSeekBar.getProgress());
  }

  // init views
  LayoutInflater inflater = (LayoutInflater) mSeekBar.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  mPopupView = inflater.inflate(mPopupLayout, null);
  mPopupView.measure(makeMeasureSpec(0, UNSPECIFIED), makeMeasureSpec(0, UNSPECIFIED));
  mPopupTextView = mPopupView.findViewById(android.R.id.text1);
  mPopupTextView.setText(popupText != null ? popupText : String.valueOf(mSeekBar.getProgress()));
  // init popup
  mPopup = new PopupWindow(mPopupView, WRAP_CONTENT, WRAP_CONTENT, false);
  mPopup.setAnimationStyle(mPopupAnimStyle);
}
 
Example 6
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
public void doClick(View view) {
	//AlertDialog����
	// 1.����AlertDialog
	// AlertDialog dialog = new AlertDialog.Builder(this).setTitle("title")
	// .setMessage("message").create();
	// 2.ͨ��Dialog��ȡWindow
	// Window window = dialog.getWindow();
	// window.setGravity(Gravity.BOTTOM); // �˴���������dialog��ʾ��λ��
	// 3.��Window�������ö������
	// window.setWindowAnimations(R.style.dialogWindowAnim); // ��Ӷ���
	// ��ʾ�Ի���
	// dialog.show();
	
	//popupwindow�Ķ���
	View popupwindow = getLayoutInflater().inflate(
			R.layout.popupwindow_layout, null);
	PopupWindow pop = new PopupWindow(popupwindow,
			ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT);
	pop.setAnimationStyle(R.style.dialogWindowAnim);
	pop.showAsDropDown(view);
}
 
Example 7
Source File: BootstrapDropDown.java    From Android-Bootstrap with MIT License 6 votes vote down vote up
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));
    }
}
 
Example 8
Source File: EmojiPopup.java    From Emoji with Apache License 2.0 6 votes vote down vote up
EmojiPopup(@NonNull final EmojiPopup.Builder builder, @NonNull final EditText editText) {
  this.context = Utils.asActivity(builder.rootView.getContext());
  this.rootView = builder.rootView.getRootView();
  this.editText = editText;
  this.recentEmoji = builder.recentEmoji;
  this.variantEmoji = builder.variantEmoji;

  popupWindow = new PopupWindow(context);
  variantPopup = new EmojiVariantPopup(rootView, internalOnEmojiClickListener);

  final EmojiView emojiView = new EmojiView(context,
          internalOnEmojiClickListener, internalOnEmojiLongClickListener, builder);

  emojiView.setOnEmojiBackspaceClickListener(internalOnEmojiBackspaceClickListener);

  popupWindow.setContentView(emojiView);
  popupWindow.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
  popupWindow.setBackgroundDrawable(new BitmapDrawable(context.getResources(), (Bitmap) null)); // To avoid borders and overdraw.
  popupWindow.setOnDismissListener(onDismissListener);

  if (builder.keyboardAnimationStyle != 0) {
    popupWindow.setAnimationStyle(builder.keyboardAnimationStyle);
  }

  rootView.addOnAttachStateChangeListener(onAttachStateChangeListener);
}
 
Example 9
Source File: PopupActivity.java    From ans-android-sdk with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    PopupWindow win = window.getPopupWindow();
    int id = v.getId();
    if (id == R.id.translate_bt) {
        win.setAnimationStyle(R.style.animTranslate);
    } else if (id == R.id.alpha_bt) {
        win.setAnimationStyle(R.style.animAlpha);
    } else if (id == R.id.scale_bt) {
        win.setAnimationStyle(R.style.animScale);
    } else if (id == R.id.rotate_bt) {
        win.setAnimationStyle(R.style.animRotate);
    }
    window.showAtLocation(activityPopup, Gravity.BOTTOM, 0, 0);
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.alpha = 0.3f;
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    getWindow().setAttributes(lp);
}
 
Example 10
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 11
Source File: TweetProgressDialog.java    From YiBo with Apache License 2.0 6 votes vote down vote up
private void initComponents() {
       LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
       View contentView = inflater.inflate(R.layout.widget_dialog_tweet_progress, null);
       tvDialogTitle = (TextView)contentView.findViewById(R.id.tvDialogTitle);
       lvAccount = (ListView)contentView.findViewById(R.id.lvAccount);
    btnPositive = (Button)contentView.findViewById(R.id.btnPositive);
    btnNegative = (Button)contentView.findViewById(R.id.btnNegative);
    btnPositive.setEnabled(false);

    listAdapter = new TweetProgressListAdapter(context);
    lvAccount.setAdapter(listAdapter);

    progressWindow = new PopupWindow(contentView, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    progressWindow.setBackgroundDrawable(new ColorDrawable(Color.argb(100, 158, 158, 158)));
    progressWindow.setFocusable(true);
    progressWindow.setOutsideTouchable(true);
    progressWindow.setAnimationStyle(android.R.anim.fade_in);
}
 
Example 12
Source File: TestCaseListActivity.java    From Android-Plugin-Framework with MIT License 5 votes vote down vote up
private static void testPopupWindow(View rootView) {

        View view = LayoutInflater.from(rootView.getContext()).inflate(R.layout.pop_test, null);
        PopupWindow window = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        window.setAnimationStyle(R.style.PopupAnimation);
        window.setOutsideTouchable(true);
        window.setFocusable(true);
        window.setBackgroundDrawable(new BitmapDrawable());
        window.showAtLocation(rootView, Gravity.BOTTOM, 0, 0);
    }
 
Example 13
Source File: MainApp.java    From NetKnight with Apache License 2.0 5 votes vote down vote up
private void initmPopupWindowViewright() {
        View customView = getActivity().getLayoutInflater().inflate(R.layout.right_top,
                null, false);
        // 创建PopupWindow实例,200,150分别是宽度和高度
        popupWindow = new PopupWindow(customView, 500, 800);
        // 设置动画效果 [R.style.AnimationFade 是自己事先定义好的]
        popupWindow.setAnimationStyle(R.style.ways);
        popupWindow.setOutsideTouchable(true);
        // 自定义view添加触摸事件
        customView.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (popupWindow != null && popupWindow.isShowing()) {
                    popupWindow.dismiss();
                    popupWindow = null;
                }

                return false;
            }
        });


        /** 在这里可以实现自定义视图的功能 */
        Button btn_appsort = (Button) customView.findViewById(R.id.btn_appsort);
//        Button btn_netusesort = (Button) customView.findViewById(R.id.btn_netusesort);
        Button btn_netlimitsort = (Button) customView.findViewById(R.id.btn_netlimitsort);
//        Button btn_wifiusesort = (Button) customView.findViewById(R.id.btn_wifisort);
        Button btn_wifilimitsort = (Button) customView.findViewById(R.id.btn_wifilimitsort);
        btn_appsort.setOnClickListener(this);
//        btn_netusesort.setOnClickListener(this);
        btn_netlimitsort.setOnClickListener(this);
//        btn_wifiusesort.setOnClickListener(this);
        btn_wifilimitsort.setOnClickListener(this);
    }
 
Example 14
Source File: PopWindowImg.java    From Android with MIT License 5 votes vote down vote up
private void touchLong() {
    LogManager.getLogger().d(Tag, "touchLong");

    View gifView = LayoutInflater.from(getContext()).inflate(R.layout.view_popupimg, null);
    GifView gif = (GifView) gifView.findViewById(R.id.gif);
    gif.setGifResource(filePath);
    gif.play();

    int[] location = SystemUtil.locationOnScreen(this);
    window = new PopupWindow(gifView, SystemUtil.dipToPx(100), SystemUtil.dipToPx(100));
    window.setAnimationStyle(R.style.Dialog);
    window.setBackgroundDrawable(getResources().getDrawable(R.drawable.shape_trans_while));
    window.setFocusable(true);
    window.setOutsideTouchable(true);
    window.update();

    //location[1] = location[1] - getHeight();

    if ((location[0] - SystemUtil.dipToPx(25) - SystemUtil.dipToPx(10)) <= SystemUtil.dipToPx(10)) {
        location[0] = SystemUtil.dipToPx(10);
    } else if ((location[0] - SystemUtil.dipToPx(25) + SystemUtil.dipToPx(100) + SystemUtil.dipToPx(20)) >= SystemDataUtil.getScreenWidth()) {
        location[0] = SystemDataUtil.getScreenWidth() - SystemUtil.dipToPx(10) - SystemUtil.dipToPx(100);
    } else {
        location[0] = location[0] - SystemUtil.dipToPx(25);
    }
    window.showAtLocation(this, Gravity.TOP | Gravity.START, location[0], location[1] - SystemUtil.dipToPx(100));
}
 
Example 15
Source File: BasicActivity.java    From EasyPopup with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 16
Source File: ScalingActivityAnimator.java    From Android-ScalingActivityAnimator with Eclipse Public License 1.0 5 votes vote down vote up
private void showPopupWindow() {
    mPopupWindow = new PopupWindow(mPopupView, ViewGroup.LayoutParams.MATCH_PARENT, popHeight, true);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setAnimationStyle(R.style.showScalingAnimation);
    mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
        @Override
        public void onDismiss() {
            resumeAnim();
        }
    });
    mPopupWindow.showAtLocation(mPopupView, Gravity.BOTTOM, 0, 0);
}
 
Example 17
Source File: FloatingToolbar.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static PopupWindow createPopupWindow(ViewGroup content) {
    ViewGroup popupContentHolder = new LinearLayout(content.getContext());
    PopupWindow popupWindow = new PopupWindow(popupContentHolder);
    popupWindow.setClippingEnabled(false);
    popupWindow.setAnimationStyle(0);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    content.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    popupContentHolder.addView(content);
    return popupWindow;
}
 
Example 18
Source File: BasicActivity.java    From EasyPopup with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 19
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 20
Source File: PopupWindowList.java    From WechatPopupWindow with Apache License 2.0 4 votes vote down vote up
public void show() {
    if (mAnchorView == null) {
        throw new IllegalArgumentException("PopupWindow show location view can  not be null");
    }
    if (mItemData == null) {
        throw new IllegalArgumentException("please fill ListView Data");
    }
    mPopView = new ListView(mContext);
    mPopView.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.white));
    mPopView.setVerticalScrollBarEnabled(false);
    mPopView.setDivider(null);
    mPopView.setAdapter(new ArrayAdapter<>(mContext,
            android.R.layout.simple_list_item_1, mItemData));
    if (mItemClickListener != null) {
        mPopView.setOnItemClickListener(mItemClickListener);
    }
    mPopView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    if (mPopupWindowWidth == 0) {
        mPopupWindowWidth = mDeviceWidth / 3;
    }
    if (mPopupWindowHeight == 0) {
        mPopupWindowHeight = mItemData.size() * mPopView.getMeasuredHeight();
        if (mPopupWindowHeight > mDeviceHeight / 2) {
            mPopupWindowHeight = mDeviceHeight / 2;
        }
    }
    mPopupWindow = new PopupWindow(mPopView, mPopupWindowWidth, mPopupWindowHeight);
    if (mPopAnimStyle != 0) {
        mPopupWindow.setAnimationStyle(mPopAnimStyle);
    }
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setFocusable(mModal);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable(mContext.getResources(), (Bitmap) null));


    Rect location = locateView(mAnchorView);
    if (location != null) {
        int x;
        //view中心点X坐标
        int xMiddle = location.left + mAnchorView.getWidth() / 2;
        if (xMiddle > mDeviceWidth / 2) {
            //在右边
            x = xMiddle - mPopupWindowWidth;
        } else {
            x = xMiddle;
        }
        int y;
        //view中心点Y坐标
        int yMiddle = location.top + mAnchorView.getHeight() / 2;
        if (yMiddle > mDeviceHeight / 2) {
            //在下方
            y = yMiddle - mPopupWindowHeight;
        } else {
            //在上方
            y = yMiddle;
        }
        mPopupWindow.showAtLocation(mAnchorView, Gravity.NO_GRAVITY, x, y);
    }
}