I take an example from this codelab
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return ComposeView(requireContext()).apply {
setContent {
//Column(modifier = Modifier.background(Color.LightGray)) {
//Text(text = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", modifier = Modifier.weight(1f))
val scrollState = rememberLazyListState()
LazyColumn(state = scrollState, modifier = Modifier
.background(Color.Cyan).fillMaxWidth()) {
items(100) {
Text("Item #$it")
}
}
//}
}
}
}
But latest element not visible on my scree. P.S I scrolled to the end
When add height in column - the last elements are visible, but LazyColumn
stretches over the entire height
LazyColumn(state = scrollState, modifier =
Modifier.background(Color.Cyan).fillMaxWidth().height(350.dp)) {
items(100) {
Text("Item #$it")
}
}
This happens because the column is a root element. Ok, Adding Column()
in root element and LazyColumn()
into in root, but I want the LazyСolumn
to take up the entire height
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
return ComposeView(requireContext()).apply {
setContent {
Column(modifier = Modifier.background(Color.LightGray)) {
val scrollState = rememberLazyListState()
LazyColumn(state = scrollState, modifier = Modifier
.background(Color.Cyan).fillMaxWidth()/*.height(350.dp)*/) {
items(100) {
Text("Item #$it")
}
}
}
}
}
}
The last elements are not visible
Ideally I want to make a scrolling table with a static header
UPD: When I add Text() On and Under LazyColumn(), also the last elements are not visible
setContent {
MaterialTheme {
Column(modifier = Modifier
.background(Color.LightGray)
.fillMaxSize()) {
Text(text = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", modifier = Modifier.background(Color.Red).weight(1f)
)
val scrollState = rememberLazyListState()
LazyColumn(
state = scrollState,
modifier = Modifier
.background(Color.Cyan)
.fillMaxWidth()
.weight(4f)
) {
items(100) {
Text("Item #$it")
}
}
Text(text = "!!!!!!!!!!!!!!!!!!!!", modifier = Modifier.background(Color.Red).weight(1f))
}
}
}