intoSunshine 2018-12-26 11:15 采纳率: 0%
浏览 2061

使用popupwindow时,想使背景变成无棱角的矩形,结果四角出现黑色

图片说明

效果就是这样,我想让四周的四个黑点消失,
popupwindow对应的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:id="@+id/pop_window"
    android:background="@drawable/shape_btn_dialog"
    android:layout_height="wrap_content"
    android:orientation="vertical">


</LinearLayout>

采用的drawable文件

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 圆角 -->
    <corners android:radius="7dp" /><!-- 设置圆角半径 -->

    <solid android:color="@android:color/white" /><!-- 填充的颜色 -->

    <!-- 描边 -->
    <stroke
        android:width="1dp"
        android:color="@color/white" />
</shape>

popupwindow中的item是动态添加view形成的,里面的背景我也修改了,就是不明白为甚吗出现这种情况
还有代码里我也写了

 mPopUpWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.shape_btn_dialog));
  • 写回答

2条回答 默认 最新

  • 热心市民刘先生111 2019-07-04 17:15
    关注

    popWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));

    评论

报告相同问题?