{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

LazyItemScope

@LazyScopeMarker
public interface LazyItemScope


Receiver scope being used by the item content parameter of LazyColumn/Row.

Summary

Public methods

abstract @NonNull Modifier

This modifier animates the item placement within the Lazy list.

abstract @NonNull Modifier
fillParentMaxHeight(@NonNull Modifier receiver, float fraction)

Have the content fill the Constraints.maxHeight of the incoming measurement constraints by setting the minimum height to be equal to the maximum height multiplied by fraction.

abstract @NonNull Modifier
fillParentMaxSize(@NonNull Modifier receiver, float fraction)

Have the content fill the Constraints.maxWidth and Constraints.maxHeight of the parent measurement constraints by setting the minimum width to be equal to the maximum width multiplied by fraction and the minimum height to be equal to the maximum height multiplied by fraction.

abstract @NonNull Modifier
fillParentMaxWidth(@NonNull Modifier receiver, float fraction)

Have the content fill the Constraints.maxWidth of the parent measurement constraints by setting the minimum width to be equal to the maximum width multiplied by fraction.

Public methods

animateItemPlacement

@ExperimentalFoundationApi
abstract @NonNull Modifier animateItemPlacement(
    @NonNull Modifier receiver,
    @NonNull FiniteAnimationSpec<@NonNull IntOffset> animationSpec
)

This modifier animates the item placement within the Lazy list.

When you provide a key via LazyListScope.item/LazyListScope.items this modifier will enable item reordering animations. Aside from item reordering all other position changes caused by events like arrangement or alignment changes will also be animated.

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier

var list by remember { mutableStateOf(listOf("A", "B", "C")) }
LazyColumn {
    item {
        Button(onClick = { list = list.shuffled() }) {
            Text("Shuffle")
        }
    }
    items(list, key = { it }) {
        Text("Item $it", Modifier.animateItemPlacement())
    }
}
Parameters
@NonNull FiniteAnimationSpec<@NonNull IntOffset> animationSpec

a finite animation that will be used to animate the item placement.

fillParentMaxHeight

abstract @NonNull Modifier fillParentMaxHeight(@NonNull Modifier receiver, float fraction)

Have the content fill the Constraints.maxHeight of the incoming measurement constraints by setting the minimum height to be equal to the maximum height multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole parent height. fraction must be between 0 and 1.

Regular Modifier.fillMaxHeight can't work inside the scrolling vertically layouts as the items are measured with Constraints.Infinity as the constraints for the main axis.

fillParentMaxSize

abstract @NonNull Modifier fillParentMaxSize(@NonNull Modifier receiver, float fraction)

Have the content fill the Constraints.maxWidth and Constraints.maxHeight of the parent measurement constraints by setting the minimum width to be equal to the maximum width multiplied by fraction and the minimum height to be equal to the maximum height multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole available space. fraction must be between 0 and 1.

Regular Modifier.fillMaxSize can't work inside the scrolling layouts as the items are measured with Constraints.Infinity as the constraints for the main axis.

fillParentMaxWidth

abstract @NonNull Modifier fillParentMaxWidth(@NonNull Modifier receiver, float fraction)

Have the content fill the Constraints.maxWidth of the parent measurement constraints by setting the minimum width to be equal to the maximum width multiplied by fraction. Note that, by default, the fraction is 1, so the modifier will make the content fill the whole parent width. fraction must be between 0 and 1.

Regular Modifier.fillMaxWidth can't work inside the scrolling horizontally layouts as the items are measured with Constraints.Infinity as the constraints for the main axis.