我想将PopupWindow设置为与屏幕相同。需要将 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);