Create a custom view and display in a layout view

I’ve been creating my own views for some time, but I couldn’t create them so that the preview in Android Studio displays them correctly.

I initialize user attributes using:

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

But this leads to an invisible component in the preview. Any ideas how to achieve this?

+7
source share
3 answers

You need a rebuildproject. After that, custom views previewwill work in

+13
source

. , if. ,

+3

clss attachToRoot true.

0

Source: https://habr.com/ru/post/1670075/


All Articles