Taking Android UI development to the next level
The adage goes: “a worker is only as good as their tools,” and the same applies to developers.
The ability of a developer to work quickly and efficiently is often dictated by the tools they have available. A better toolset won’t change the skill of the developer, but it does make a material difference to the time and effort required to complete a task.
In our recent online technical workshop, we spoke to Anna-Chiara Bellini, product manager for Jetpack Compose at Google, about the future of native Android UI development and what it means for the development community.
“We released Jetpack Compose – Android’s new native UI development tool – about a month ago. It’s a modern, native UI toolkit for creating UIs in a much more intuitive and powerful way, with much less code.”
Moving to a declarative model
One of the key aspects of the toolkit is that it’s a declarative UI toolkit, and Anna explains that the key objective was to simplify the process of building the UI for applications.
“In the past even creating a simple UI required a lot of code. You’d have to write the layout XML, load resources, animations, all of which were difficult with the previous toolkit.
“The reason for this is that the original UI toolkit was created at a time when the UI was fundamentally different, and less sophisticated, than today’s UI.
“If you’re familiar with classical Android development, you know that there were numerous steps you need to go through to build the UI and one problem was that part of the state was in the XML and other parts were in other views. So, changing state was very complex.”
Jetpack Compose uses a declarative framework where the state is pushed to the UI in a unidirectional manner.
“You can’t modify the UI without changing state,” she explains. “So, all you do is you set the state, and this dictates the UI. If you create a second state, then you’ll have a different UI. And this is the only way you can update the UI.”
The result of this change is that the heavy lifting has now been moved from the developer to the toolkit.
“One of the things that’s important is that the code you write isn’t all the code that’ll be executed. For some people, who want to control the behavior of individual pixels, this requires a change in the way they think. There are ways to achieve this, but it just has to be done differently,” she explains. “We’ve tried to make everything as intuitive as possible.”
Part of the reason why Bellini feels that Compose has been welcomed is the involvement of the community. “Compose is completely open-source. This allowed us to work with the community to get feedback very early on, rather than relying entirely on internal resources. We have an amazing engineering team, but having that inclusive scope allowed us to tap into a much broader pool of skills.
“We wanted to help people be productive. If you’re spending time getting things to work, then it’s not fun. By creating a closer connection between what you think and what you’re able to produce the process of building applications becomes more fun.”
One area that has always been a challenge is animations. “Modern UIs are dynamic and leverage motion much more, so we’ve tried to make this simple inside Compose,” Bellini comments. “We’ve also tried to accommodate the growing number of form factors that Android runs on. It’s not just phones anymore, but phones, tablets, Chromebooks, and wearables, just to mention a few.
“As a product manager the greatest reward is building a product that people want to use, and that they have fun. As soon as we released the first animation API, developers took it and started making animations, which was unthinkable before. And that’s just the best reward ever as a product manager.”
If you found Anna’s online technical workshop useful, check out our other on-demand webinars for more essential insights!
Are you a developer interested in growing your software engineering career? Apply to join the Andela Talent Network today.