I have a simple composable function in com.example.Example.kt:
@Preview
@Composable fun ExampleComposable() {
Text("Hello")
}
I tried to use ComposeViewAdapter like below:
<androidx.compose.ui.tooling.ComposeViewAdapter
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:composableName="com.example.ExampleKt" />
Android Studio does not show any preview of the composable in the design pane.
Also, how is ComposeViewAdapter different from androidx.compose.ui.platform.ComposeView?
Example.kt
file can have many composables, you need to specify the composable name:
<androidx.compose.ui.tooling.ComposeViewAdapter
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:composableName="com.example.ExampleKt.ExampleComposable" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With