
View view = LayoutInflater.from(this).inflate(R.layout.dialog_attention, null); AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog alertDialog = builder.create(); alertDialog.setView(view); // 这里必须这样设置,不然不透明了 alertDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); alertDialog.show();
控件布局:
android:background="@drawable/rounded_attention"
drawable文件:
// 设置颜色为透明颜色