PopupWindow不响应拖放事件

hey*_*jii 8 android drag-and-drop android-popupwindow

我的应用程序中有一个菜单图标.当我拖放一些东西时,它会显示一个弹出窗口.我需要延伸我的拖延PopupWindow.

我这样做如下.

创建了一个PopupWindow,如图所示

View popupView = View.inflate(anchorView.getContext(), R.layout.layout_popup, null);

PopupWindow popUpWindow = new PopupWindow(popupView, WindowManager.LayoutParams.WRAP_CONTENT,
                                                  WindowManager.LayoutParams.WRAP_CONTENT);
Run Code Online (Sandbox Code Playgroud)

并如图所示设置dragListener

popupView.setOnDragListener(new OnDragListener() {
            @Override
            public boolean onDrag(View view, DragEvent dragEvent) {



                    switch (dragEvent.getAction()) {
                    case DragEvent.ACTION_DRAG_STARTED:
                        Log.d("Drag", "ACTION_DRAG_STARTED");
                        break;
                    case DragEvent.ACTION_DRAG_ENDED:
                        Log.d("Drag", "ACTION_DRAG_ENDED");
                        break;
                    case DragEvent.ACTION_DRAG_ENTERED:
                        Log.d("Drag", "ACTION_DRAG_ENTERED");
                        break;
                    case DragEvent.ACTION_DRAG_EXITED:
                        Log.d("Drag", "ACTION_DRAG_EXITED");
                        break;
                    case DragEvent.ACTION_DROP:
                        Log.d("Drag", "ACTION_DROP");
                        break;
                    default:
                        break;
                    }

                return true;
            }
        });
Run Code Online (Sandbox Code Playgroud)

下面的视频显示了我想要实现的目标.

在此输入图像描述

但是popupView没有响应任何拖动事件.我也尝试过使用它DialogFragment,但它也没有帮助.任何帮助表示赞赏.

提前致谢.