我指的是this Stack Overflow问题,以便在NavigationView
中实现模糊背景,并从右侧打开抽屉。问题在于BlurAndDimView
的右重力。
当我将NavigationView
的重力设置为正确时,抽屉正常工作但模糊的视图仍保持在左侧。
当我设置BlurAndDimView
右侧的重力时,它进入中心并且抽屉消失了。
我还尝试更改public void handleScroll(float xOffset)
类的方法public void setImage(Bitmap bmp, int downSampling)
和BlurAndDimView
,如下所示 -
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();
}
但它没有用。抽屉消失了! 感谢您的帮助。