
Posted by
Today, we’re releasing the alpha of — taking the hardest, most common developer problems on Android and creating a suite of libraries that ensure high quality apps that work across all versions of the platform. Today, 84% of the top 10,000 apps in the Play store are using a Jetpack library.
Then we heard how developers love Kotlin, with over 70% of the top 1000 apps and 60% of pro Android developers using Kotlin today. The , saw reduced line count by an average of 30%.
Finally, we heard strong feedback from the community that developers like the simplicity of declarative APIs for building UI. Jetpack Compose combines all three of these: APIs for high quality apps at scale, an intuitive language, and a reactive programming model.
The alpha release includes:
- Animations
- Constraint Layout
- Initial A11Y support
- Input and Gestures
- Interoperability with Views (start mixing Composable functions in your existing app)
- Lazy Lists
- Material UI components
- Performance optimizations
- Testing
- Text and editable Text
- Theming and Graphics
- Window management
We've also added a number of new capabilities to Android Studio 4.2 canary, in close partnership with the , and change nodes by calling methods like:
button.setText(String)
container.addView(View)
img.setImageBitmap(Bitmap)These methods change the internal state of the widget. Not only can this be tedious, but updating views manually increases the likelihood of errors (e.g. forgetting to update a view).
Jetpack Compose is a fully declarative component-based approach, meaning you describe your UI as functions that transform data into a UI hierarchy. When the underlying data changes, the Compose framework automatically updates the UI hierarchy for you, making it simple to build UIs easily and quickly.
Full interop with existing Android views
Adopting any new framework is a big change for existing projects and codebases, which is why we’ve designed Compose to be as easy to adopt as Kotlin — it is fully interoperable with existing Android code, from day one.
Migrating to Compose depends on you and your team. If you're building a new app, the best option might be to implement your entire UI with Compose. We know that most of you have large existing codebases, so rather than rewriting your app, you can combine Compose with your existing UI design.
There are two main ways you can combine Compose with a view-based UI:
- You can add Compose elements into your existing UI, either by creating an entirely new Compose-based screen, or by adding Compose elements into an existing fragment or view layout.
- You can add a view-based UI element into your composable functions. Doing so lets you add non-Compose widgets, such as MapView or WebView, into a Compose-based design.
We’ve also published a new library, themes within your Compose UI.
To learn more, try the and , embeds a MapView in Compose
Powerful Tools
Jetpack Compose is built with powerful tooling in Android Studio, designed to help you iterate quickly on the piece of UI you’re working on.
The Compose layout preview enables you to preview your Compose components without having to deploy your app to a device or emulator. As you develop your app, your previews update to help you review your changes faster. To create a layout preview, write a composable function that does not take any parameters, and add the
@Preview annotationAfter you build your app, the preview function's UI appears in Studio's Preview pane.
You can also deploy a single composable to your physical device or Android Emulator. Android Studio creates a new activity containing the UI generated by that function, and deploys it to your app on the device. This lets you try out the UI on an actual device without needing to reinstall the entire app or navigate to its location.
To find a comprehensive set of Compose resources, from new .
Since we open-sourced Jetpack Compose . Join us in the discussion on the #compose channel at
SOCIAL SHARE CARD GENERATOR