I have some weird performance issues with a custom view. Here is a simplified example :
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawBitmap(bitmap, 0, 0, null);
canvas.drawText("test", 0, 30, textPaint);
}
bitmap
is a small background image. A string is drawn on top with a large text size so the top 10 (or so) pixels are cropped, which is what I want.
I have around 100 views like this in a ListView
(10 per row). Scrolling through the list is incredibly slow, but for some strange reason, it suddenly becomes smooth if I change the drawText()
coordinates so that the text fits within the bounds of the view.
What is going on? Why is it so slow to draw the text slightly outside of the bounds?
I'm running Android 4.2.2 (can't try on other versions, the emulator isn't great to test layout performance).