// LazyColumn Example // Source code file: MainActivity.kt // Display numbers 1 to 20 in a LazyColumn. // A Column renders all items, even the ones // not in the viewport, whereas a LazyColumn // only renders items in the viewport for better // performance. A LazyColumn is scrollable by // default. package it372.ssmith.lazycolumn import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.rememberScrollState import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() setContent { Layout( ) } } } @Composable fun Layout( ) { // A Column needs a variable to keep track // of the scroll state. var scrollState = rememberScrollState( ) LazyColumn(modifier = Modifier .padding(20.dp) .fillMaxSize( )) { repeat(20) { item { Text( text = "$it", modifier = Modifier .padding(20.dp), fontSize = 50.sp ) } } } } @Preview(showBackground = true) @Composable fun GreetingPreview() { Layout( ) }