https://kotlinlang.org logo
Title
r

royal10march

05/31/2018, 10:59 AM
Did you guys switch over to anko or do ye still use xml for layouts? Do you think Anko Layouts will replace xml?
l

louiscad

05/31/2018, 11:01 AM
I used Anko, then went back to xml, then did my own View DSL that you can try: https://github.com/LouisCAD/Splitties/tree/master/viewdsl To make it short: it is lighter than Anko, and more flexible. I've been using it in production for months
❤️ 1
e

edwardwongtl

05/31/2018, 11:02 AM
Still xml, cause the preview of anko is often broken lol
❤️ 1
l

louiscad

05/31/2018, 11:02 AM
Missing flexibility in Anko layouts and low re-usability in xml was my primary incentive to make Splitties View DSL.
e

edwardwongtl

05/31/2018, 11:03 AM
Xml is low re-usability?
l

louiscad

05/31/2018, 11:15 AM
Yes, no extension functions, tightly coupled to code in host Activity/Fragment
g

gildor

05/31/2018, 11:17 AM
XML, especially with constraint layout. I still have filling that declarative XML is better choice.
1
e

edwardwongtl

05/31/2018, 11:30 AM
xml can be decouple easily and recompose just like DSL using
<include>
, if you have ALL xml tightly coupled to activity/fragment, there must be something wrong
1
r

rkeazor

05/31/2018, 11:32 AM
XML is way better especially with constraint layouts... Anko, is a cute project, but having to do all that nesting can be annoying. it will never replace XML. And I mean never lol
❤️ 1
1
l

louiscad

05/31/2018, 11:33 AM
@edwardwongtl Where all those findViewById are done? In an Activity or a Fragment, right?
I wouldn't say xml is way better, but I'd say it's better supported in the IDE (especially with ConstraintLayout).
e

edwardwongtl

05/31/2018, 11:35 AM
They can be done any where as long as you have the
View
, it can be inside a viewholder of recyclerview
l

louiscad

05/31/2018, 11:36 AM
Yes, but then, your ui is split between an xml file and a source code file
e

edwardwongtl

05/31/2018, 11:36 AM
Much much better support for xml, especially the preview
s

sindrenm

05/31/2018, 12:04 PM
Same for me. Would love to make views programmatically if the tools supported it properly.
l

louiscad

05/31/2018, 12:07 PM
@sindrenm Did you try Splitties View DSL I mentioned above? Tools support is good enough for me, I can use preview if needed, and Kotlin support is all that is needed in regards of IDE support
s

sindrenm

05/31/2018, 12:09 PM
@louiscad: I haven't tried it yet, although I saw you mentioned it some time ago in another thread! Will give it a go in the near future on a personal project. 😒imple_smile:
l

louiscad

05/31/2018, 12:10 PM
@sindrenm You should try the sample before trying it in your project, so you can get to know it without writing code
👍 1