LoginSignup
2
3

More than 5 years have passed since last update.

Androidで部分的なViewをぼかす

Posted at

build.gradle

defaultConfig {
  // for blurview
  renderscriptTargetApi 25
  renderscriptSupportModeEnabled true
}

dependencies {
  compile 'com.eightbitlab:blurview:1.3.0'
}

activity_main.xml

<eightbitlab.com.blurview.BlurView
  android:id="@+id/blurview"
  android:layout_width="match_parent"
  app:blurOverlayColor="@android:color/transparent">
</eightbitlab.com.blurview.BlurView>

blurOverlayColor は標準の transparent を指定。

MainActivity.java

final float radius = 16;
final View decorView = getWindow().getDecorView();
final ViewGroup rootView = (ViewGroup) decorView.findViewById(R.id.activity_main);
final Drawable windowBackground = decorView.getBackground();

BlurView blurView = (BlurView) findViewById(R.id.blurview);
blurView.setupWith(rootView)
        .windowBackground(windowBackground)
        .blurAlgorithm(new RenderScriptBlur(this, true))
        .blurRadius(radius);

検討したもの

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3