anko icon indicating copy to clipboard operation
anko copied to clipboard

Support View classes preview in IDE

Open yanex opened this issue 9 years ago • 3 comments

yanex avatar Dec 03 '15 23:12 yanex

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).

yanex avatar Dec 03 '15 23:12 yanex

This would be immensely helpful, for a couple of reasons, when you have to extend View instead of implementing AnkoComponent:

  1. When one needs to override a method of a View
  2. It is sometimes handy for a View to have to implement some kind of an interface. This is impossible to achieve with AnkoComponent when AnkoComponents are nested in a view tree - the AnkoComponent instance is often lost and forget after it produced the View.
  3. It's not possible to inflate AnkoComponent from layout.xml. Inflating from layout.xml is immensely helpful when gradually converting the UI.
  4. It's arguably easier to work with a View (since there's just one instance of View - this so you can add utility methods directly to the View's extender) than with AnkoComponent (since that's a factory producing Views, often one has to rely that the createView has been called only once, to e.g. add utility methods which modify the views).

mvysny avatar Feb 28 '17 05:02 mvysny

This would be very helpful for non-Kotlin projects. Especially when comes understanding that XML, themes, and layout inflater ultimately suck. :)

Miha-x64 avatar Jan 23 '19 15:01 Miha-x64