我想要像这样的模糊图像,我需要将它设置为RelativeLayout,它应该创建如下所示的模糊图像:

我使用了github的blurry库,它使用这段代码完成了我的所有工作,但我只能将其设置为Imageview,而不能将其设置为RelativeLayout。
Blurry.with(context).capture(view).into(imageView);所以,请给我解决方案。
发布于 2017-04-17 16:47:40
无需使用任何库文件,只需在可绘制文件夹中创建一个图层列表XML文件并使用它即可。
要获得模糊效果,请在可绘制文件夹中创建blur.xml文件。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/nature" /> <!-- change @drawable/nature with your desired image -->
<item>
<shape android:shape="rectangle">
<!-- You can use from 1% transparency to 100% transparency, according to your need,-->
<solid
android:color="#80FFFFFF"/> <!-- Here transparency level is 80%-->
</shape>
</item>
</layer-list>现在将其用作布局文件中的背景图像。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blur">
完成,..。
发布于 2017-04-17 14:29:54
愿这对你有所帮助
自己保持高度和宽度
示例:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:adjustViewBounds="true"
android:alpha="0.3"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:src="@drawable/abcd" />
</RelativeLayout>发布于 2017-04-17 14:35:30
您可以使用毕加索的BlurTransformation并将图像加载到自定义目标(在您的示例中为RelativeLayout)中,如下所示
Picasso
.with(context)
.load(UsageExampleListViewAdapter.eatFoodyImages[0])
.transform(new BlurTransformation(context))
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});https://stackoverflow.com/questions/43446124
复制相似问题