androidandroid-fragmentsandroid-libraryblurry

Android library Blurry not working for me,blurring effects do not apply


i am using blurry library for my project but it doesn't seem to work

i want to have a blurred backround in a relative layout,so can anybody help me with some ideas for that

here is the code in my fragment

 public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    imageView=(ImageView)view.findViewById(R.id.imageView2);
    imageButton=(ImageButton)view.findViewById(R.id.imageButton);
    imageButton2=(ImageButton)view.findViewById(R.id.imageButton2);
    imageButton3=(ImageButton)view.findViewById(R.id.imageButton3);
    textView=(TextView)view.findViewById(R.id.textView);
    seekBar=(SeekBar)view.findViewById(R.id.seekBar);
    rl=(RelativeLayout)view.findViewById(R.id.psrl);
    rl1=(RelativeLayout)view.findViewById(R.id.rl1);

    imageButton.setOnClickListener(this);
    imageButton2.setOnClickListener(this);
    imageButton3.setOnClickListener(this);
    seekBar.setOnSeekBarChangeListener(this);
    createMediaPlayer();
    setAlbumImage();
    runnable=new Runnable() {
        @Override
        public void run() {
            seekBar.setProgress(MainActivity.mediaPlayer.getCurrentPosition());
            handler.postDelayed(runnable,1000);
        }
    };
    handler.postDelayed(runnable,1000);
    rl.setBackground(d);
    Blurry.with(getContext()).radius(25).sampling(2).async().animate(500).onto((ViewGroup)view.findViewById(R.id.psrl));
}

and here is the xml code

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:id="@+id/psrl"
>
<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:background="#7e838c"
    android:alpha="1.0"
    android:id="@+id/rl1">
<TextView
    android:layout_width="210dp"
    android:layout_height="wrap_content"
    android:layout_marginLeft="15dp"
    android:layout_marginTop="8dp"
    android:ellipsize="marquee"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:gravity="center"
    android:marqueeRepeatLimit="marquee_forever"
    android:paddingLeft="5dp"
    android:paddingRight="5dp"
    android:scrollHorizontally="true"
    android:singleLine="true"
    android:text="Medium Text"
    android:textSize="15dp"
    android:id="@+id/textView"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />
</RelativeLayout>
<ImageView
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:id="@+id/imageView2"
    android:layout_marginTop="109dp"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:scaleType="fitXY"
    android:background="@drawable/ic_launcher"
    android:adjustViewBounds="true"
    android:padding="8dp"
    android:alpha="1"
    android:cropToPadding="true"/>

<SeekBar
    android:layout_width="370dp"
    android:layout_height="30dp"
    android:id="@+id/seekBar"
    android:layout_above="@+id/imageButton"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="38dp" />

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton"
    android:background="@drawable/custom2"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="60dp"
    android:layout_centerHorizontal="true"/>
<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton2"
    android:background="@drawable/previous"
    android:layout_alignTop="@+id/imageButton"
    android:layout_alignLeft="@+id/imageView2"
    android:layout_alignStart="@+id/imageView2" />

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton3"
    android:background="@drawable/skip"
    android:layout_alignTop="@+id/imageButton"
    android:layout_alignRight="@+id/imageView2"
    android:layout_alignEnd="@+id/imageView2" />

</RelativeLayout>

only backround is set but blurring effects do not apply.Can anybody help?

here is the build.gradle

 android {
compileSdkVersion 24
defaultConfig {
    applicationId "com.example.abhinav.mymusicplayer"
    minSdkVersion 16
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
buildToolsVersion '24.0.2'
productFlavors {
}
}
repositories {
maven {
    url "https://jitpack.io"

}
}
dependencies {
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'jp.wasabeef:blurry:2.1.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.github.moondroid.coverflow:library:1.0'
compile 'com.github.davidschreiber:FancyCoverFlow:a54a1e7'
compile files('libs/picasso-2.5.2.jar')
compile files('libs/carousel-api-v1.jar')
}

Solution

  • Ok so here are the steps i followed when i wanted a Blurred Image.

    Modify your build.gradle like this:

    android {
    
        defaultConfig {
            minSdkVersion 18
            targetSdkVersion 25
    
            renderscriptTargetApi 25 <-- must match your targetSdkVersion
            renderscriptSupportModeEnabled true
    
        }
    }
    

    The repeat the library procedure as it is. If this does not fix the things try this library:

    https://github.com/jrvansuita/GaussianBlur which worked for me like a charm!!

    Hope it helps!!