anko
anko copied to clipboard
Support View classes preview in IDE
Preview is currently provided only for AnkoComponent implementations. It is quite useful to have it for View classes written in Kotlin (and maybe in Java as well).
This would be immensely helpful, for a couple of reasons, when you have to extend View instead of implementing AnkoComponent:
- When one needs to override a method of a View
- It is sometimes handy for a View to have to implement some kind of an interface. This is impossible to achieve with
AnkoComponentwhen AnkoComponents are nested in a view tree - the AnkoComponent instance is often lost and forget after it produced the View. - It's not possible to inflate AnkoComponent from layout.xml. Inflating from layout.xml is immensely helpful when gradually converting the UI.
- It's arguably easier to work with a View (since there's just one instance of
View-thisso you can add utility methods directly to the View's extender) than withAnkoComponent(since that's a factory producing Views, often one has to rely that thecreateViewhas been called only once, to e.g. add utility methods which modify the views).
This would be very helpful for non-Kotlin projects. Especially when comes understanding that XML, themes, and layout inflater ultimately suck. :)