Learning Android Development

Jetpack Compose Enables JSON Defined View Layout

Making a more dynamic layout from the server payload

Photo by Hal Gatewood on Unsplash

Conventionally in Android, we use RecyclerView to show a list of items. Each item is normally layout in the same structure through the same ViewHolder. In order to have different structures of view, we’ll create different ViewHolder of different view types, as shared in this StackOverflow.

When using the conventional XML-based definition to define it, dynamically constructing layout is difficult if not impossible.

But with Jetpack Compose, this becomes feasible, especially given that the layout construction using Rows and Columns is relatively performant (as shared in the article below).

Here, I’m sharing one of the ideas shared in my previous article, where we can dynamically construct the layout of the components of a list.

I’ll be showing what it can do first, and then share how it is done beneath.

--

--