I have some problem with AlertDialog when I'm trying to blur his Background with Bitmap class.
For some reason, when I'm calling pop up , it's blurring only part of screen. As you can see in the attached image, the layout of dialog not filling the screen. When I'm blurring other layouts, for example fragments , it's working good .
public void errorPopup(String error) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mActivity);
LayoutInflater inflater = mActivity.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.popup_layout, null);
dialogBuilder.setView(dialogView);
Bitmap map = new BlurUtils().takeScreenShot(mActivity);
Bitmap fast = new BlurUtils().fastblur(map, 50);
Drawable drawable = new BitmapDrawable(mResources, fast);
dialogView.setBackground(drawable);
final AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();
TextView tvErrorMessage = alertDialog.findViewById(R.id.tvErrorMessage);
tvErrorMessage.setText(error);
Button btnAccept = alertDialog.findViewById(R.id.btnAccept);
btnAccept.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
alertDialog.cancel();
}
});
}
Dialog layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:background="@drawable/popup_background">
<TextView
android:id="@+id/tvErrorMessage"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/no_error_message"
android:textAlignment="center" />
<Button
android:id="@+id/btnAccept"
android:layout_width="150dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@null"
android:stateListAnimator="@null"
android:text="@string/try_again" />
</RelativeLayout>
</RelativeLayout