I'm sorry for the long title, but it's a little difficult to explain.
I have a LazyColumn Composable into a FragmentContainerView. This container at the same time into a ConstraintLayout, sharing the space with another container.
This is the activity layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.MainActivity">
<androidx.fragment.app.FragmentContainerView
android:id="@+id/containerAddModule"
android:name="com.example.AddModuleFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/containerListModules"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_weight="1"
tools:layout="@layout/fragment_add_module" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/containerListModules"
android:name="com.example.ModulesListFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/containerAddModule"
app:layout_constraintVertical_weight="2"
tools:layout="@layout/fragment_item_list" />
</androidx.constraintlayout.widget.ConstraintLayout>
Both container are organized with a vertical chain with weighted heights.
This is the fragment_item_list layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.compose.ui.platform.ComposeView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/compose_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
And this is the Composable content for the compose_view:
binding.composeView.setContent {
val listaModulos = viewModel.allModules.observeAsState(emptyList())
MaterialTheme {
Surface() {
LazyColumn(Modifier.fillMaxHeight()) {
items(50) { index ->
Text("Test $index")
}
}
}
}
}
With this approach, when scrolling down the LazyColumn, i can only display to the item 39. I cant see 11 items...
On the other hand, using a LinearLayout instead of Constraint Layout in the main layout it works right...
Someone can explain this?