diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/images/ImageOptimizationSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/images/ImageOptimizationSnippets.kt new file mode 100644 index 000000000..7675746f5 --- /dev/null +++ b/compose/snippets/src/main/java/com/example/compose/snippets/images/ImageOptimizationSnippets.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2026 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.compose.snippets.images + +import androidx.compose.runtime.Composable +import androidx.compose.ui.graphics.painter.Painter + +// [START android_compose_graphics_images_optimization] +// Prefer this: +@Composable +fun MyImage(url: String) { + +} +// Over this: +@Composable +fun MyImage(painter: Painter) { + +} +// [END android_compose_graphics_images_optimization] diff --git a/compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt b/compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt index 7f221bb56..231a45f58 100644 --- a/compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt +++ b/compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt @@ -854,3 +854,13 @@ fun ScrollingGrid() { } } // [END android_compose_layout_scrollable_grid] + +@Composable +private fun LazyVerticalGridAdaptiveSample() { + // [START android_compose_layout_scrollable_grid_adaptive] + LazyVerticalGrid( + columns = GridCells.Adaptive(minSize = 20.dp) + ) {} + // [END android_compose_layout_scrollable_grid_adaptive] +} +