3
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

Androidで部分的なViewをぼかす

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);

検討したもの

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Sign upLogin
3
Help us understand the problem. What are the problem?