androidx.fragment.compose
Insert package level documentation here
Classes
FragmentState |
Holder for the fragment state. |
Composables
AndroidFragment |
Allows for adding a |
rememberFragmentState |
Creates a |
Extension functions summary
ComposeView |
Fragment.content(content: @Composable () -> Unit)Wrapper function that handles the setup for creating a custom Fragment that hosts Compose content. |
Extension functions
Fragment.content
fun Fragment.content(content: @Composable () -> Unit): ComposeView
Wrapper function that handles the setup for creating a custom Fragment that hosts Compose content. It automatically sets the ViewCompositionStrategy to ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed.
It should be used as part of the implementation of Fragment.onCreateView and requires a context meaning the fragment must be attached to a FragmentManager.
class ExampleFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
) = content {
val viewModel: ExampleViewModel = viewModel()
// put your @Composable content here
}
}