0

I need to add a transparent background with a blur image, which the background image needs to get blured.

I was referring to this answer. [https://stackoverflow.com/a/21052060/3650133][1] I'm getting a transparent background, but my background image does not get blur. This is my main layout.

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/mainmenu"
    android:orientation="vertical" >
    </Linearlayout>

And what is window in this code in OnCreate() method (in the above link). Since nothing was recognized as window I used it like getWindow().

final Activity activity = this;
        final View content = activity.findViewById(android.R.id.content).getRootView();
        if (content.getWidth() > 0) {
            Bitmap image = BlurBuilder.blur(content);
            getWindow().setBackgroundDrawable(new BitmapDrawable(activity.getResources(), image));
        } else {
            content.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    Bitmap image = BlurBuilder.blur(content);
                    getWindow().setBackgroundDrawable(new BitmapDrawable(activity.getResources(), image));
                }
            });
        }

Please help me with this. Thanks in advance.

Community
  • 1
  • 1
Isuru
  • 161
  • 1
  • 2
  • 13

0 Answers0