David Guo
David Guo

Reputation: 1759

The logic about onDraw of ImageView

The class MyImageView extended ImageView, In method onDraw(), I have following code:

@Override
protected void onDraw(Canvas canvas) {
    this.setImageBitmap(someBitmap);
    super.onDraw(canvas);
}

Although the code works, I am wonder why onDraw has not benn called infinitely, since setImageBitmap will call onDraw -->right or not? I am still want to know is there performance issue for above code?

Upvotes: 2

Views: 935

Answers (1)

Romain Guy
Romain Guy

Reputation: 98501

setImageBitmap() will call invalidate() which will in turn call onDraw() later on. What you are doing is a really bad idea :)

Upvotes: 2

Related Questions