Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

view大小改变后,阴影显示异常 #2

Open
Nstd opened this issue Jul 6, 2018 · 1 comment
Open

view大小改变后,阴影显示异常 #2

Nstd opened this issue Jul 6, 2018 · 1 comment

Comments

@Nstd
Copy link

Nstd commented Jul 6, 2018

如果view的高度增加,阴影会被截断

@Nstd
Copy link
Author

Nstd commented Jun 7, 2021

是因为这里的67行缓存了图片的尺寸导致的。
mRect 可以一开始就初始化一个对象(去掉66行),然后67行改成设置

this.mRectF.set((float)(bounds.left + this.mShadowRadius - this.mOffsetX), (float)(bounds.top + this.mShadowRadius - this.mOffsetY), (float)(bounds.right - this.mShadowRadius - this.mOffsetX), (float)(bounds.bottom - this.mShadowRadius - this.mOffsetY));

@Override
public void draw(@NonNull Canvas canvas) {
if (mRectF == null) {
Rect bounds = getBounds();
mRectF = new RectF(bounds.left + mShadowRadius - mOffsetX, bounds.top + mShadowRadius - mOffsetY, bounds.right - mShadowRadius - mOffsetX,
bounds.bottom - mShadowRadius - mOffsetY);
}
if (mPaint == null) {
initPaint();
}
canvas.drawRoundRect(mRectF, mRadius, mRadius, mPaint);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant