Implementing custom view with MVVM

Viewed 7286

I have found the android data binding with a custom view explanation, but this doesn't work for me because I do not understand this very well and also I have a little bit different case.

My idea: I need canvas so I can draw something on it. I have made a class(CustomView) that extends the View class. In CustomView class I have made instance of service that is in charge of drawing, and in the overridden onDraw method I passed canvas to service class so the app can draw.

The problem: In activity I have used setContentView(new CustomView());, but this will not work if I want to use MVVM design pattern. How can I separate these and make it to work with MVVM data binding? I do not understand how and where to setup CustomView so it can be fetched/binded by view with data binding?

Please bear with me, I am new to android and do not have enough experience. Thanks :)

1 Answers
Related