`
yangsongjing
  • 浏览: 251461 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

android 自定义dialog不会出现黑边,透明

阅读更多
private void stopDialog() {
final AlertDialog dlg = new AlertDialog.Builder(this).create();
dlg.show();
Window window = dlg.getWindow();
// window.setLayout(421, 234);
window.setContentView(R.layout.detail_stop);
LinearLayout linear1 = (LinearLayout) window.findViewById(R.id.linear1);
// 为确认按钮添加事件,执行退出应用操作
linear1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (dlg.isShowing()) {
dlg.dismiss();
}
read();
}
});

}




// 显示透明的对话框 

    AlertDialog alertDialog = new AlertDialog.Builder(this).setMessage( 

            "透明对话框").setPositiveButton("确定", null).create(); 

    Window window = alertDialog.getWindow(); 

    WindowManager.LayoutParams lp = window.getAttributes(); 

    // 设置透明度为0.3 

    lp.alpha = 0.6f; 

    window.setAttributes(lp); 

    alertDialog.show();
2
6
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics