Jetpack Compose 1.2.0 & Jetpack Compose Wear 1.0.0 are out
Jetpack Compose 1.2.0 and Jetpack Compose Wear 1.0.0 were released today. Here is the summary of what changed.
This article was featured in Android Weekly #529 π
What's new in Jetpack Compose 1.2.0
The following APIs are now part of the stable release:
- LazyHorizontalGrid and LazyVerticalGrid (Video)
- βAdded a userScrollEnabled parameter to prevent scrolling of lazy layouts.
- WindowInsets. It is an API that supports insets in your app (previously available in the respective Accompanist artifact)
- Modifier.nestedScroll()
- New easing curves were added.
- Improved mouse support: added Modifier.pointerHoverIcon() PointerEventType.Scroll PointerEvent.scrollDelta
New Experimental APIs
- New LazyLayout composable for creating efficient scrollable layouts.
- New Modifier.overscroll() to create overscroll effects to your scrollable containers.
- New downloadable fonts API
- New pluralStringResource() composable.
- Improved Test APIs. See performKeyInput and testTagAsResourceId().
Bug Fixes
Most notable bug fixes:
- Animations now follow the "Animation duration scale" developer setting.
TextField
now handles button button presses the same was asEditText
does.
How to install Jetpack Compose 1.2.0 in your Android project
Make sure to include Jetpack Compose in your project, then update the dependencies in your app/build.gradle
file:
dependencies {
implementation "androidx.compose.animation:animation:1.2.0"
implementation "androidx.compose.foundation:foundation:1.2.0"
implementation "androidx.compose.material:material:1.2.0"
implementation "androidx.compose.runtime:runtime:1.2.0"
implementation "androidx.compose.ui:ui:1.2.0"
}
What's new in Jetpack Compose Wear 1.0.0
This is the 1.0.0 release. Includes new wear specific Compose dependencies with a variety of Wear composables.
There is a new Google library called Horologist that brings support to common patterns that are not available to Compose yet (seems like the Wear version of Accompanist).
New Preview available for Wearable devices:
import androidx.compose.ui.tooling.preview
@Preview(
device = Devices.WEAR_OS_LARGE_ROUND,
showSystemUi = true,
backgroundColor = 0xff000000,
showBackground = true
)
@Composable
fun PreviewCustomComposable() {
CustomComposable(...)
}
How to install Jetpack Compose for Wear
Add the respective wear dependencies in your app/build.gradle
file:
dependencies {
implementation "androidx.compose.animation:animation:1.2.0"
implementation "androidx.compose.foundation:foundation:1.2.0"
implementation "androidx.compose.runtime:runtime:1.2.0"
implementation "androidx.compose.ui:ui:1.2.0"
// wear dependencies
implementation "androidx.wear.compose:compose-foundation:1.0.0"
implementation "androidx.wear.compose:compose-material:1.0.0"
implementation "androidx.wear.compose:compose-navigation:1.0.0"
}
WARNING: Do not include androidx.compose.material:material
in your wear project.
According to the documentation these are the difference in dependencies you have to use:
Wear OS Dependency (androidx.wear.*) | Comparison | Mobile Dependency (androidx.*) |
---|---|---|
androidx.wear.compose:compose-material | instead of | androidx.compose.material:material |
androidx.wear.compose:compose-navigation | instead of | androidx.navigation:navigation-compose |
androidx.wear.compose:compose-foundation | in addition to | androidx.compose.foundation:foundation |
Read the full update at the official Compose 1.2.0 announcement and Compose Wear 1.0.0 announcement