Learning Android Development

Jetpack Compose View & Android View Comparison

Learning through a side-by-side comparison of the two styles

Photo by Stephen Phillips - Hostreviews.co.uk on Unsplash

The popularity of Jetpack Compose is increasingly getting the attention of Android mobile developers, while it is still in its Alpha state. Couple with SwiftUI in iOS development, this paradigm of development is undoubtedly will be the next phase of mobile development trend.

For those who have yet to see what Jetpack Compose looks like in detail, here I provide a simple side-by-side comparison of a simple custom view I created, named ToggleButton (a button that toggle Stop to Start and vice versa upon click click).

This will not provide you the full insight of Jetpack Compose, but a good initial glimpse of how different it is from the current conventional view

The code

Before we get into the the differences, let’s look at the code for both, to get a feel of their differences.

The functionality is simple

  • Both have an initial state of False (Text = Start → indicate click to start)
  • Upon click, it will turn to True (Text = Stop → indicate click to stop)
  • There’s also has a callback function…

--

--