Skip to content

Instantly share code, notes, and snippets.

@nsmirosh
Created July 1, 2025 09:31
Show Gist options
  • Select an option

  • Save nsmirosh/1ebfbed171907cfdd647f7bc9aed8b6b to your computer and use it in GitHub Desktop.

Select an option

Save nsmirosh/1ebfbed171907cfdd647f7bc9aed8b6b to your computer and use it in GitHub Desktop.
Vertical and Horizontal Previews
import android.content.res.Configuration
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.tooling.preview.Devices
@Preview(showBackground = true)
@Composable
fun DefaultPreview() {
MyScreen()
}
@Preview(name = "Small Phone", device = Devices.NEXUS_ONE, showBackground = true)
@Composable
fun SmallPhonePreview() {
MyScreen()
}
@Preview(name = "Pixel 5", device = Devices.PIXEL_5, showBackground = true)
@Composable
fun PixelPreview() {
MyScreen()
}
@Preview(name = "Tablet 7\"", device = Devices.NEXUS_7, showBackground = true)
@Composable
fun Tablet7Preview() {
MyScreen()
}
@Preview(name = "Tablet 10\"", device = Devices.NEXUS_10, showBackground = true)
@Composable
fun Tablet10Preview() {
MyScreen()
}
@Preview(name = "Landscape", device = "spec:width=1280dp,height=800dp,dpi=440", showBackground = true)
@Composable
fun LandscapePreview() {
MyScreen()
}
@Preview(name = "Foldable", device = Devices.FOLDABLE, showBackground = true)
@Composable
fun FoldablePreview() {
MyScreen()
}
@Preview(name = "Font Scale 1.5x", fontScale = 1.5f, showBackground = true)
@Composable
fun FontScalePreview() {
MyScreen()
}
@Preview(name = "Dark Theme", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = true)
@Composable
fun DarkThemePreview() {
MyScreen()
}
// LANDSCAPE PREVIEWS
@Preview(
name = "Landscape Small Phone",
device = "spec:width=480dp,height=320dp,dpi=240",
showBackground = true
)
@Composable
fun LandscapeSmallPhonePreview() {
MyScreen()
}
@Preview(
name = "Landscape Medium Phone (Pixel 5)",
device = "spec:width=732dp,height=411dp,dpi=440",
showBackground = true
)
@Composable
fun LandscapePixelPreview() {
MyScreen()
}
@Preview(
name = "Landscape Foldable",
device = "spec:width=840dp,height=600dp,dpi=420",
showBackground = true
)
@Composable
fun LandscapeFoldablePreview() {
MyScreen()
}
@Preview(
name = "Landscape Tablet 10\"",
device = "spec:width=1280dp,height=800dp,dpi=240",
showBackground = true
)
@Composable
fun LandscapeTabletPreview() {
MyScreen()
}
@Preview(
name = "Landscape Font Scale 1.5x",
device = "spec:width=732dp,height=411dp,dpi=440",
fontScale = 1.5f,
showBackground = true
)
@Composable
fun LandscapeFontScalePreview() {
MyScreen()
}
@Preview(
name = "Landscape Dark Theme",
device = "spec:width=732dp,height=411dp,dpi=440",
uiMode = Configuration.UI_MODE_NIGHT_YES,
showBackground = true
)
@Composable
fun LandscapeDarkPreview() {
MyScreen()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment