From the course: Intermediate Kotlin for Android Developers

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Anko layouts: Basics

Anko layouts: Basics

From the course: Intermediate Kotlin for Android Developers

Start my 1-month free trial

Anko layouts: Basics

- [Instructor] In order to work successfully with Anko layouts, you need to understand its use of the AnkoContext and Anko components. First, you can think of the AnkoContext as the container for all of your Android goodies. It's an interface that holds a reference to the context, which is needed to create views programmatically, the owner of the created views, and the view itself. Notice that it also implements another interface, the ViewManager. The ViewManager contains a few methods for working with views, the most important of which is the addView method. This takes in a view you want to add, and then the LayoutParams, which describe how this view should be positioned in its parent. And that's it for the AnkoContext. Next up is the Anko component. This is where we define what views we want to have created. This can be anything, from an entire screen's layout to just a simple component. And these views are defined using Anko's DSL. DSL, as a refresher, stands for Domain-Specific…

Contents