Необходимо установить позицию PopupWindow в соответствии с экраном - PullRequest
0 голосов
/ 22 октября 2018

Я хочу установить PopupWindow так же, как screen.Нужно установить PopupWindow стрелка и сообщение больше кнопки в противоположном направлении.

LayoutInflater inflater = (LayoutInflater)
getSystemService(LAYOUT_INFLATER_SERVICE);

View customView = inflater.inflate(R.layout.popup_chat_options, null);
mPopupWindow = new PopupWindow(
customView,
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
mPopupWindow.setAnimationStyle(R.style.CustomAnimationTopToBottom);
mPopupWindow.setOutsideTouchable(true);
mPopupWindow.setFocusable(true);
mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

View view_popup_notification = customView.findViewById(R.id.view_popup_notification);

final View view = mPopupWindow.getContentView();
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);

mPopupWindow.showAsDropDown(anchorView,
0,
-(anchorView.getMeasuredHeight() + customView.getMeasuredHeight()),
(from == 1) ? Gravity.NO_GRAVITY : Gravity.NO_GRAVITY);

enter image description here

...