1

In my custom-drawn view I use the Canvas.drawPaint(Paint) method. But the preview in Android Studio displays this message:

The graphics preview in the layout editor may not be accurate: 
    - Canvas.drawPaint is not supported

It's easy to replace drawPaint with drawRect, but the javadoc to drawPaint says: This is equivalent (but faster) to drawing an infinitely large rectangle with the specified paint.

My question is: can I check, if I'm drawing in preview mode, and conditionally use either method? Or some other workaround to make preview working and keep the performance?

Oliv
  • 10,221
  • 3
  • 55
  • 76

1 Answers1

3

You can use View's built-in isInEditMode() function as documented here: http://developer.android.com/reference/android/view/View.html#isInEditMode%28%29

You can also find other methods in this thread: Custom Android Views in Eclipse Visual Editor

Good luck!

Community
  • 1
  • 1
Or Polaczek
  • 126
  • 4