主要注意的是在资源引用的地方
alertdialog.Builder(this,R.style.dialogNoBg).create();
<!--dialog去阴影--> <style name="dialogNoBg"> <item name="android:background">#00000000</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsFloating">true</item> </style>
如果引用后还是没效果,
在自定义的布局里面根Layout布局背景设置为”#00000000”
源代码:
private AlertDialog dialog;
private void showdialogCashOut() {
dialog = new AlertDialog.Builder(this,R.style.dialogNoBg).create();
View view = View.inflate(this, R.layout.cash_see_out_dialog, null);
dialog.getWindow().setContentView(view);
TextView tv_money = (TextView) dialog.findViewById(R.id.tv_money);
tv_money.setText(Html.fromHtml("<font color='#FF2850'>注意:</font>"+getResources().getString(R.string.cash_out_dialog)));
TextView cancle_ye = (TextView) view.findViewById(R.id.dialog_cancel);
cancle_ye.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
TextView yes_ye = (TextView) view.findViewById(R.id.dialog_yes);
yes_ye.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
}

以上这篇自定义AlertDialog去除黑色背景的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持华域联盟。
声明:本站(华域联盟www.cnhackhy.com)所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)