qq_o哇_0
//按钮点击事件
public void cilk1(View view){
//使用深色背景 主题
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this,AlertDialog.THEME_HOLO_DARK);
//这三个按钮是系统给的,只在Android4.x 有效,导的是这个包import android.app.AlertDialog
//AlertDialog.Builder builder=new AlertDialog.Builder(this); //先得到构造器
//设置图标
builder.setIcon(R.mipmap.ic_launcher);
builder.setTitle("谁是你的女神???");
builder.setMessage("章泽天是我的女神。。。。");
//setPositiveButton设置确定按钮最有
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
//setNegativeButton设置最左按钮
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
//setNeutralButton设置中间按钮
builder.setNeutralButton("忽略", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setCancelable(false);
//设置半透明
AlertDialog mDialog=builder.create();
WindowManager.LayoutParams wmParams = mDialog.getWindow().getAttributes();
//wmParams.format = PixelFormat.TRANSPARENT; 内容全透明
wmParams.format = PixelFormat.TRANSLUCENT;
wmParams.alpha=0.5f;
//dialog设置各种属性
mDialog.getWindow().setAttributes(wmParams);
//参数都设置完成了,创建并显示出来
mDialog.show();
}