我想模糊這樣的形象,我需要將其設置爲RelativeLayout
,它應該像下面給出這一形象創造模糊圖像:如何模糊圖像在Android和它設置爲相對佈局
我使用了github的blurry
庫,它使用這段代碼完成了我所有的工作,但我可以將其設置爲Imageview
而不是RelativeLayout
。
Blurry.with(context).capture(view).into(imageView);
所以,請給我解決方案。
我想模糊這樣的形象,我需要將其設置爲RelativeLayout
,它應該像下面給出這一形象創造模糊圖像:如何模糊圖像在Android和它設置爲相對佈局
我使用了github的blurry
庫,它使用這段代碼完成了我所有的工作,但我可以將其設置爲Imageview
而不是RelativeLayout
。
Blurry.with(context).capture(view).into(imageView);
所以,請給我解決方案。
願這可以幫助你
自己保持高度和寬度
例子: -
<?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>
這不是我需要的解決方案。它只是減少我的形象的亮度謝謝你。 – Pedo
嘗試RenderScript
和FastBlur
技術通過trickyandroid.com
解釋你可以用畢加索的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) {
}
});
謝謝,但這種方式只是模糊高達25半徑,我希望它高達50或100在我的問題我上傳的圖像有更多的模糊半徑,我想要的。請給我一個這樣做的方法。抱歉,因爲我的筆記本電腦沒有工作一個月,所以很遲纔回復。 – Pedo
它可以不使用任何庫文件來完成,只是創建圖層列表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">
做,...
https://android-arsenal.com/details/1/5385 – Viven
與相對佈局的模糊'到()'mehtod嘗試。例如。 (內容).radius(25).sampling(2).onto((ViewGroup)rootView);' –
@PriyankPatel但它不能正常工作,它會在我啓動新活動時模糊不清。 – Pedo