I am referring this Stack Overflow Question to achieve blurry background in the NavigationView
with the drawer opening from the Right. The problem is with Right gravity of the BlurAndDimView
.
When I set the gravity of the NavigationView
to right the drawer works properly but the blurry view stays still in the Left.
When I set the Gravity of the BlurAndDimView
right it went in the Centre and the drawer disappeared.
I Also tried to alter the methods public void handleScroll(float xOffset)
and public void setImage(Bitmap bmp, int downSampling)
of the BlurAndDimView
class as follows-
public void handleScroll(float xOffset) {
if (image != null) {
rectSrc.left = getWidth()-(int) (image.getWidth() * xOffset);
rectDst.left = rectSrc.left * downSampling;
rectRest.right = rectDst.left;
/*rectSrc.right = (int) (image.getWidth() * xOffset);
rectDst.right = rectSrc.right * downSampling;
rectRest.left = rectDst.right;*/
dimPaint.setAlpha((int) (xOffset * MAX_DIM_ALPHA));
invalidate();
}
}
public void setImage(Bitmap bmp, int downSampling) {
Bitmap cropped = Bitmap.createBitmap(bmp, 0, 0, menuWidth / downSampling, getHeight() / downSampling);
this.image = Blur.fastblur(getContext(), cropped, BLUR_RADIUS);
/*rectSrc = new Rect(0, 0, bmp.getWidth(), bmp.getHeight());
rectDst = new Rect(0, 0, menuWidth, getHeight());
rectRest = new Rect(menuWidth, 0, getWidth(), getHeight());*/
rectSrc = new Rect(0, 0, bmp.getWidth(), bmp.getHeight());
rectDst = new Rect(getWidth() - menuWidth, 0, getWidth(), getHeight());
rectRest = new Rect(0, 0, getWidth() - menuWidth, getHeight());
this.downSampling = downSampling;
invalidate();
}
But It didn't work . Drawer Disappeared! Thanks for the help in advance.