Michael Chourdakis
Michael Chourdakis

Reputation: 11158

Custom View redraws only once, then onDraw is called but screen is not updated

I have an View subclass and it call onDraw but the screen is not updated at once.

Note that, when I set my app to compatibility SDK (Target SDK Api Level 8) it works. Target SDK 14 it is never gets updated.

The onDraw is called, but it's like drawing to a sink.

What could be wrong?

EDIT: I saw that it's actually an GLES20Recording canvas for drawing, but this doesn't explain why it doesn't redraw. When I set the view to software rendering mode, it draws.

Upvotes: 1

Views: 1184

Answers (3)

Michael Chourdakis
Michael Chourdakis

Reputation: 11158

I found the solution, Views have to be software accelerated.

view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

Stupid, but it works.

Upvotes: 1

Md Abdul Gafur
Md Abdul Gafur

Reputation: 6201

With API 14 your app is hardware accelerated. Are you sure you are calling invalidate() on the View that contains this drawPath code?

Thanks

Upvotes: 0

petey
petey

Reputation: 17140

To force a view to draw, to call invalidate() or postInvalidate(). This can be done on any view subclass.

Upvotes: 0

Related Questions