Skip to content
🤔 Documentation issue? Report or edit

Preview

Preview

You can use the @Preview annotation to preview compose functions inside Android Studio. Preview can not be used on Composables that have parameters without a default parameter.

@Preview
@Composable
fun TextDemo(){
    Text("Hello")
}

@Preview(name = "MyPreviewName")
@Composable
fun TextDemo2(){
    Text("Hello")
}
Android Studio Preview

Group Previews

 @Preview(group = "TestGroup1")
The Preview annotation has a group parameter. You can use it to set a group name to your previews.

The layout preview will now have an option to filter all the previews by the group name.

Interactive Previews

Above a generated preview in Android Studio you will find an “Interactive” Button. It will open your Composable in an interactive preview mode where can try your Composable directly inside Android Studio.

See also:


Last update: April 7, 2022