Android删除PopupWindow背景

Jov*_*van 4 android

我使用PopupWindow类创建自定义弹出窗口.

但是当我在main上添加layout_margin(在我的示例中为15dp)时,会有透明的灰色背景.

如何删除透明背景?

请看图片

在此输入图像描述

编辑这里是我的代码

    window = new PopupWindow(customTool.getContext());
    window.setWidth(WindowManager.LayoutParams.FILL_PARENT);
    window.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
    window.setTouchable(true);
    window.setFocusable(true);
    window.setOutsideTouchable(true);
    window.setAnimationStyle(R.style.Animations_PopDownMenu_Left);
window.setContentView(customTool);
    window.showAtLocation(customTool, Gravity.NO_GRAVITY, 0, 100);
Run Code Online (Sandbox Code Playgroud)

jkh*_*uw1 6

嗯 - 尝试设置弹出对话框尝试yourDiag.setBackgroundDrawable(null);

  • 而``setBackgroundDrawable(null);`我使用`new BitmapDrawable()` (3认同)
  • 当我使用`setBackgroundDrawable(null);`透明背景消失了,但setOutsideTouchable不起作用.我实现`setTouchInterceptor`但是当我设置`setBackgroundDrawable(null);`不工作.建议? (2认同)