Create custom view and display in Layout Preview

Maximiliano Ambrosini picture Maximiliano Ambrosini · Feb 17, 2017 · Viewed 14.1k times · Source

I've been creating custom views for a while now, but never got to make them in a way that the Android Studio preview displays them correctly.

I initialize the custom attributes using:

if (!isInEditMode()) {
...
}

But this results in an invisible component on preview. Any ideas on how to achieve this?

Answer

mohax picture mohax · Feb 13, 2018

You need to rebuild project. After that custom views in preview will work