Android rectf warning
•
Android
I drew an ellipse on the canvas:
RectF f = new RectF(-r, -r, r, r);
canvas.drawOval(f , mPaint);
Why do I see a warning on rectf?
resolvent:
This is what it says: executing a new rectf in OnDraw will create an object every time you draw anything. This may be many objects. Just use one rectf:
RectF mRect = new RectF();
protected void onDraw(Canvas canvas) {
mRect.set(-r, -r, r, r);
canvas.drawOval(mRect, mPaint);
}
It should be clear that your original code is logically correct. This is only a performance improvement (although very important)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码