https://kotlinlang.org logo
#android
Title
# android
g

Gunslingor

08/11/2019, 3:25 PM
Any idea's why this font isn't wrapping correctly?
ahh... it was the scroll view inside the tableview that needed to be setup. This is my first real android app. Still don't fully understand all these XML files... even why they exist. Sort of getting the impression I should create a row template in XML and pass it values from Kotlin rather than trying to build it with kotlin.
k

kevindmoore

08/11/2019, 4:12 PM
This view looks like it could use a RecyclerView instead. A bit more complex but you don't have to use a ScrollView
a

Adam Powell

08/11/2019, 4:13 PM
either way your instinct is right, constructing view trees by hand is pretty tedious and the workflow is optimized around inflating xml templates and binding values instead
g

Gunslingor

08/11/2019, 4:13 PM
thanks I'll check it out... learning android is a little tougher than I anticipated.
a

Adam Powell

08/11/2019, 4:13 PM
you might find the data binding library useful, or if you're up for using some prerelease tooling, the new viewbinding stuff
k

kevindmoore

08/11/2019, 4:14 PM
I would recommend an online class. Pretty hard to do on your own
a

Adam Powell

08/11/2019, 4:14 PM
yeah the learning curve is really steep in the beginning. We're working on it. 🙂 there's some neat stuff incubating over in #compose too
g

Gunslingor

08/11/2019, 4:15 PM
Yeah? I've learned so many languages on my own... android is a little unique
k

kevindmoore

08/11/2019, 4:15 PM
I'm learning a new language/platform now, and taking a class really shorted the learning curve
g

Gunslingor

08/11/2019, 4:16 PM
I guess that makes sense, I took a kotlin for java developers course recently.
a

Adam Powell

08/11/2019, 4:16 PM
https://developer.android.com/courses/ has some codelabs that you might find useful, it's been a while since I looked over the material presented there though to have an opinion on it
k

kevindmoore

08/11/2019, 4:16 PM
Also, sign up for a newsletter like: https://androidweekly.net/
g

Gunslingor

08/11/2019, 4:19 PM
thanks. i guess my biggest questions revolve around how the xml gets turned into a layout... and why the folder structure is the way it is, how to modify and build on it.
a

Adam Powell

08/11/2019, 4:24 PM
reflection to invoke the view constructor and plain old calls to
addView
as it recurses through the tags
aapt does some compression on the xml file at build time so that it's cheaper to parse at runtime
if you see reference to 'binary xml' around the docs that's what it's talking about
g

Gunslingor

08/11/2019, 4:26 PM
interesting
l

louiscad

08/11/2019, 5:27 PM
If you're going to make UIs with code on Android, until Jetpack Compose, I recommend you try Splitties Views DSL (which I'm the author of), it makes it significantly nicer to use than without Kotlin extensions like you currently do: https://github.com/LouisCAD/Splitties/tree/master/modules/views-dsl I've been using it for about two years now, used xml the two years before.
g

gildor

08/12/2019, 2:19 AM
If you are beginner I highly recommend to use XML and do not even try build layouts in code, just use standard Android practises from official guides. Doing this from code will not help at all, actually lack of tooling support such as preview, styles etc will make everything much harder if you don't know how to manage this from codr
✔️ 5