Open ncwuguowei opened 1 year ago
Post your setup.
Normally it shouldn't matter, since the bitmap from internalCanvas
is then being drawn on the system canvas
anyway.
And drawing on canvas
is also confined within the view bounds
Hi, I found the cause of the problem.
I set the overlayColor is RED for demo
when RN setClipChildren(false) default
when setClipChildren(true) for example
blurView.postDelayed(new Runnable() {
@Override
public void run() {
Log.i("AndroidBlurView", "blurView width = " + blurView.getWidth() +
" ,blurView height = " + blurView.getHeight());
ViewGroup parent = (ViewGroup) blurView.getParent();
parent.setClipChildren(true);
}
}, 10 * 1000);
3.the error exist in React Native project , but I can not find in normal andord project even I set setClipChildren(false), why it draw in correct whthin the view bounds?
so we should draw overlayColor with correct size and draw in onPrewDraw() by updateBlur().
this React Native project use BlurView in Android , you can see this https://github.com/Kureev/react-native-blur
Ha ha, I can show error in your demo ~~~ Only drop outline provider in MainActivity, and set clicpChildren(false)
main_activity.xml , set root view clipChildren(false)
MainActivity.java
drop the outline code , and to set overlayColor Red show clearly.
private void initView() {
viewPager = findViewById(R.id.viewPager);
tabLayout = findViewById(R.id.tabLayout);
bottomBlurView = findViewById(R.id.bottomBlurView);
topBlurView = findViewById(R.id.topBlurView);
// Rounded corners + casting elevation shadow with transparent background
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// topBlurView.setClipToOutline(true);
// topBlurView.setOutlineProvider(new ViewOutlineProvider() {
// @Override
// public void getOutline(View view, Outline outline) {
// topBlurView.getBackground().getOutline(outline);
// outline.setAlpha(1f);
// }
// });
// }
radiusSeekBar = findViewById(R.id.radiusSeekBar);
root = findViewById(R.id.root);
}
I think the outline affect the bulrView draw, so the demo usually can not find this bug.
Please include: 1) Library version master branch 2). the blurview draw the overlayColor is incorrect. PreDrawBlurController#public boolean draw(Canvas canvas) { .... canvas.restore(); // NOTE: need delete there, because only draw overlayColor to blurView content. // current canvas.drawColor(overlayColor) will cause the whole canvas(decorView) draw the overlayColer if (overlayColor != TRANSPARENT) { canvas.drawColor(overlayColor); } return true; }
and method blurAndSave() to add draw overlayColor ,mix to bulred bitmap