自定义AlertDialog去除黑色背景 自定义AlertDialog去除黑色背景的解决办法

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

自定义AlertDialog去除黑色背景 自定义AlertDialog去除黑色背景的解决办法

wapchief   2021-03-31 我要评论

主要注意的是在资源引用的地方

AlertDialog.Builder(this,R.style.dialogNoBg).create(); 

这里要自定义sytle

 <!--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去除黑色背景的解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们