ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setContentView(View.inflate(this, R.layout.layout_popup, null));
popupWindow.setBackgroundDrawable...然后popupWindow.setBackgroundDrawable(new ColorDrawable(0x00000000));这个很有意思....在高版本的android中(比如8.0), 实测可以不写, 但是低版本就不行了(比如4.1), 低版本不写的话, 会导致点击返回或者是屏幕其它地方无法取消弹窗, 所以稳妥起见还是加上, 并设置一个透明色...用API16的虚拟机.
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7.app.AlertDialog.Builder...就是在弹窗中填充自定义view. 当然啦, 还有adapter的方法, 但是我暂时不打算在这次的文章中写, 因为用adapter的时候太多了, 可能要下次弄个单独的部分.
?
举个栗子
<?