A Better Way of Creating Android Views with JetPackCompose
The Android platform has undergone significant changes over its lifetime, from using the Model-View-Controller pattern to the Model-View-ViewModel pattern recommended by Google. The usage of XML files for defining layouts has remained relatively consistent, but new features like Kotlin's DSL have been introduced. JetPack Compose is a new way of dealing with UI that utilizes Kotlin and custom DSL language to configure screen layouts, define themes, manage view state, and add UI animations, achieving a declarative approach similar to ReactNative, Flutter, and iOS apps. With Android Studio Arctic Fox 2020.3.1 or newer, developers can create new projects using the Empty Compose Activity template and start defining views in the setContent lambda function, which has replaced XML files for view definitions. The JetPack Compose DSL provides basic building blocks for UI applications, including columns, rows, boxes, and composable components that can be extracted into separate methods annotated with the Composable annotation. As of June 2021, JetPack Compose is not stable yet but has great potential and will likely become a new standard for Android UI in the future.
Company
Vonage
Date published
June 3, 2021
Author(s)
Igor Wojda
Word count
993
Language
English
Hacker News points
None found.