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

勾的绘制速度好慢 #10

Open
mogazheng opened this issue Aug 16, 2016 · 4 comments
Open

勾的绘制速度好慢 #10

mogazheng opened this issue Aug 16, 2016 · 4 comments

Comments

@mogazheng
Copy link

勾的绘制速度好慢,有没有什么办法加快呢

@andyxialm
Copy link
Owner

andyxialm commented Aug 16, 2016

可修改line 283, line 311.

float step = (mWidth / 20.0f) < 3 ? 3 : (mWidth / 20.0f);

'step' 变量为控制单次绘制对勾的增量。需要注意,如果单次绘制的增量过大,会导致不够平滑。

不过这确实是设计上的一个缺陷,如果CheckBox宽高比较小的话,的确会绘制比较慢,这个我等不忙后改一下。你暂时可以用上面的解决方案。

@mogazheng
Copy link
Author

一般checkbox都比较小,不会有明显的平滑问题,像我这边项目的checkbox在调试机上实际才56px,我改了代码分成5次绘制,效果好多了,一次绘制耗时10-20ms左右,5次不超过100ms,加上背景圆设置为200ms,一共不超过300ms,对于checkbox来说感觉比较能接受。

@mogazheng
Copy link
Author

还有个小问题,
if (mDrewDistance < mLeftLineDistance + mRightLineDistance) {
postDelayed(new Runnable() {
@OverRide
public void run() {
postInvalidate();
}
}, 10);
}
这里应该改成
if (mDrewDistance - step < mLeftLineDistance + mRightLineDistance)
不然会少了最后一次对勾的绘制,按下去的瞬间才绘制最后一次,又变长了一点点。

@hexiangbing
Copy link

Sometimes will appeal the hook is incompleteness. And I make it to be. if (mDrewDistance - step < mLeftLineDistance + mRightLineDistance) .But some problems also appeal the postInvalidate exect all the time.

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

3 participants