3

I use https://github.com/wasabeef/Blurry library.

in Onclick, the following code works.

private boolean blurred = false;

if (blurred) {
      Blurry.delete((ViewGroup) findViewById(R.id.content));
    } else {
      long startMs = System.currentTimeMillis();
      Blurry.with(MainActivity.this)
          .radius(25)
          .sampling(2)
          .async()
          .animate(500)
          .onto((ViewGroup) findViewById(R.id.content));
    }
blurred = !blurred;

But when I add the following code in OnCreate, it doesn't work.

Blurry.with(MainActivity.this)
      .radius(25)
      .sampling(2)
      .async()
      .animate(500)
      .onto((ViewGroup) findViewById(R.id.content));
Sevle
  • 3,109
  • 2
  • 19
  • 31
Thang BA
  • 162
  • 3
  • 13

1 Answers1

2

Your library uses view size

  factor.width = target.getMeasuredWidth();
  factor.height = target.getMeasuredHeight();

When you call it. In onCreate your view has not created. you should move it for example to onWindowFocusChanged(boolean hasFocus) or use any suggestion from answer of for3st by this link

Community
  • 1
  • 1