我有一张图片,上面有一个 TextView 。我想知道如何模糊 textview 的背景(仅图像的一部分)以使其更具可读性。我试过查看 Blurry 库,但它似乎只能模糊整个图片。
最佳答案
添加此自定义 BlurView 解决方案:https://github.com/mmin18/RealtimeBlurView
然后将您的 BlurView 放置在布局中的 TextView 后面:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<com.github.mmin18.widget.RealtimeBlurView
android:id="@+id/textview_blurview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/my_textview"
android:layout_alignBottom="@+id/my_textview"
android:layout_alignStart="@+id/my_textview"
android:layout_alignLeft="@+id/my_textview"
android:layout_alignEnd="@+id/my_textview"
android:layout_alignRight="@+id/my_textview"/>
<TextView
android:id="@+id/my_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text in front of blur view"/>
</RelativeLayout>
最后,在代码中根据需要设置模糊度和颜色
blurView.setBlurRadius(80.0f);
blurView.setOverlayColor(R.color.background_blur_color);
关于java - 我如何在 android studio 中模糊我的 textview 的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51732622/