PreviewDevices
Multi-preview annotation for testing Composables across various device sizes.
Applying this annotation to a Composable function automatically generates preview variants for phone, landscape, foldable, and tablet screen sizes. This ensures your UI is responsive and adapts correctly to different form factors.
Device Specifications
Phone: 360×640dp @ 480dpi (standard portrait phone)
Landscape: 640×360dp @ 480dpi (phone in landscape orientation)
Foldable: 673×841dp @ 480dpi (unfolded device like Galaxy Fold)
Tablet: 1280×800dp @ 480dpi (10-inch tablet)
Usage
@PreviewDevices
@Composable
fun MyScreenPreview() {
JetpackTheme {
MyScreen(
screenData = MyScreenData(/* preview data */),
onAction = {}
)
}
}Content copied to clipboard
Combining with Other Preview Annotations
@PreviewDevices
@PreviewThemes // Also test light and dark themes
@Composable
fun MyComponentPreview() {
JetpackTheme {
MyComponent()
}
}Content copied to clipboard