📜  blurview android github - Java (1)

📅  最后修改于: 2023-12-03 15:13:40.423000             🧑  作者: Mango

BlurView Android Github - Java

BlurView is a library that provides a fast and easy way to add blur effects to different views and layouts in Android applications. This library is available on Github and can be used with Java.

Features
  • Easy to use
  • Fast and efficient
  • Different blur levels
Installation
  1. Add the following dependency to your build.gradle file:
dependencies {
    implementation 'com.eightbitlab:blurview:1.6.6'
}
  1. Sync your project
Usage
BlurView
  1. Add the following code to your activity layout file:
<com.eightbitlab.supportrenderscriptblur.SupportRenderScriptBlurView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/blurView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:overlayColor="#66FFFFFF"
    app:blurRadius="10dp"
    app:fallbackColor="#CCCCCC" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <!-- Your view here -->

    </LinearLayout>
</com.eightbitlab.supportrenderscriptblur.SupportRenderScriptBlurView>
  1. In your activity code, initialize the blur view and set the view to be blurred:
BlurView blurView = findViewById(R.id.blurView);
blurView.setupWith(myView)
     .setBlurAlgorithm(new SupportRenderScriptBlur(this))
     .setBlurRadius(25f)
     .setBlurAutoUpdate(true)
     .setHasFixedTransformationMatrix(true);
BlurLayout
  1. Add the following code to your activity layout file:
<com.eightbitlab.supportrenderscriptblur.SupportRenderScriptBlurLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/blurLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:blurRadius="15dp" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <!-- Your view here -->

    </LinearLayout>
</com.eightbitlab.supportrenderscriptblur.SupportRenderScriptBlurLayout>
  1. In your activity code, initialize the blur layout and set the view to be blurred:
BlurLayout blurLayout = findViewById(R.id.blurLayout);
blurLayout.setBlurAlgorithm(new SupportRenderScriptBlur(this))
         .setBlurRadius(15f)
         .setHasFixedTransformationMatrix(true)
         .setOverlayColor(Color.parseColor("#99000000"));

View target = findViewById(R.id.targetView);
blurLayout.attachHoverView(target);
Conclusion

BlurView is a great library that makes it easy to add blur effects to any view or layout in Android. It's fast, efficient, and easy to use. If you're looking to add blur effects to your app, give BlurView a try!