我指的是这个堆栈溢出问题,以实现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();
}
但它没有用。抽屉不见了!我在这里先向您的帮助表示感谢。