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")
}
Group Previews¶
@Preview(group = "TestGroup1")
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