【发布时间】:2017-10-14 23:01:03
【问题描述】:
我正在使用在RecycleView 容器中弹出的自定义弹出菜单。
当触摸的视图在底部打开时,弹出菜单会隐藏RecycleView 下方的控件。
在这种情况下,我想调整弹出窗口的位置,使弹出窗口精确到所需的距离以便菜单保持在容器内。
这应该很容易,但我在获取坐标和从处理项目点击的Adapter 内部应用计算时遇到了困难。
这是我到目前为止所管理的:
void show(FragmentActivity activity, View touchedView, DataItem item) {
LayoutInflater layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View popupView = layoutInflater.inflate(R.layout.popup_menu, null);
PopupWindow popupWindow = new PopupWindow(
popupView,
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setOutsideTouchable(true);
bind(popupWindow, popupView, item);
//draws the menu perfectly bellow the touched element,but doesn't take in account the parent view area
popupWindow.showAsDropDown(touchView);
}
【问题讨论】:
标签: android popup android-popupwindow