Android Libs模糊不起作用

时间:2016-03-16 06:38:46

标签: android blur blurry

我使用 https://github.com/wasabeef/Blurry库。

<{1>}中的

,以下代码有效。

Onclick

但是当我在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; 中添加以下代码时,它不起作用。

OnCreate

1 个答案:

答案 0 :(得分:2)

您的图书馆使用view size

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

当你打电话的时候。在onCreate中,您的视图尚未创建。您应将其移至例如onWindowFocusChanged(boolean hasFocus)或使用for3st通过this link

回答的任何建议