v1.6.0 BlurView No Longer Works on Emulator
See original GitHub issueThank you for updating the library and continuously improving the features!
I am trying to upgrade my libraries to use v1.6.0 but I run into an issue where the BlurView doesn’t render because the new BlurViewFacade might be interfering.
v1.6.0
v1.5.0 (working)
I’m extending BlurView because I need to apply rounded corners to the blur. This is my custom BlurView with rounded corners:
package stream.customalert.ui;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewOutlineProvider;
import eightbitlab.com.blurview.BlurView;
import eightbitlab.com.blurview.RenderScriptBlur;
import stream.customalert.CustomAlertDialogue;
public class CustomBlurDialogue extends BlurView {
public CustomBlurDialogue(Context context) {
super(context);
init();
}
public CustomBlurDialogue(Context context, AttributeSet attrs) {
super(context, attrs);
init();
initCorners(context);
}
public CustomBlurDialogue(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
initCorners(context);
}
private void init() {
}
private void initCorners(Context context) {
setRoundedCorners(CustomAlertDialogue.Units.dpToPx(context, 15));
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
public void create(View decorView, float radius) {
ViewGroup rootView = decorView.findViewById(android.R.id.content);
Drawable windowBackground = decorView.getBackground();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
setupWith(rootView)
.setFrameClearDrawable(windowBackground)
.setBlurAlgorithm(new RenderScriptBlur(getContext()))
.setBlurRadius(radius)
.setHasFixedTransformationMatrix(true);
}
}
/**
* Set Rounded Corners on Lollipop and above. Use rounded drawable and disable blur below Lollipop.
* @param cornerRadius - set corner radius in pixels.
*/
private void setRoundedCorners(int cornerRadius) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setBackground(new RoundedCornersDrawable(cornerRadius));
setOutlineProvider(ViewOutlineProvider.BACKGROUND);
setClipToOutline(true);
}
}
}
Before the introduction of BlurViewFacade, it was working because the blur was handled within the BlurView class. Now, it appears the blur is handled by the BlurViewFacade. Do you have any ideas how I can extend BlurView successfully?
Perhaps there is a way to have BlurViewFacade without breaking BlurView’s extensibility or maybe I’m using BlurViewFacade wrong?
Thanks for taking a look!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Fixed in 1.6.1. Btw you should now be able to use a regular dialog in your lib and the blur position will be calculated properly
Thanks you so much! You’re amazing 😃