📅  最后修改于: 2023-12-03 15:13:40.423000             🧑  作者: Mango
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.
dependencies {
implementation 'com.eightbitlab:blurview:1.6.6'
}
<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>
BlurView blurView = findViewById(R.id.blurView);
blurView.setupWith(myView)
.setBlurAlgorithm(new SupportRenderScriptBlur(this))
.setBlurRadius(25f)
.setBlurAutoUpdate(true)
.setHasFixedTransformationMatrix(true);
<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>
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);
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!