简体   繁体   English

AlertDialog 背景模糊的问题

[英]Problem with blurred background on AlertDialog

I'm tried to blur background using this post: https://stackoverflow.com/a/21278278/10837992 .我试图使用这篇文章模糊背景: https : //stackoverflow.com/a/21278278/10837992

It's work good but i have a little problem with the size of the dialog.它工作得很好,但我对对话框的大小有一点问题。

  1. I'm created custom layout :我创建了自定义布局:

  2. I'm changed the realization of the method.我改变了方法的实现。

     AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); LayoutInflater inflater = this.getLayoutInflater(); View dialogView = inflater.inflate(R.layout.alert_dialog_layout, null); builder.setView(dialogView); TextView title = dialogView.findViewById(R.id.Title); TextView desc = dialogView.findViewById(R.id.Desc); title.setText("Title"); desc.setText("Desc"); AlertDialog alert = builder.create(); Bitmap map = new BlurUtils().takeScreenShot(getActivity()); Bitmap fast = new BlurUtils().fastblur(map, 50); final Drawable drawable = new BitmapDrawable(getResources(), fast); alert.getWindow().setBackgroundDrawable(drawable); alert.show();
  3. While running this method, the size of the Dialog is cropped: Screenshoot:运行此方法时,对话框的大小被裁剪:屏幕截图: 在此处输入图片说明

Ok , I find a solution:好的,我找到了解决方案:

Just added Theme to AlertDialog.Builder.刚刚将主题添加到 AlertDialog.Builder。

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),android.R.style.Theme_DeviceDefault_Light_NoActionBar_Fullscreen);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM