Kaydırma tuşunu etkinleştirmek için bir düğme oluşturun
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Kullanıcının bir listedeki belirli bir noktaya hızlıca kaydırmasına olanak tanıyan bir düğme göstererek zamandan tasarruf edebilir ve kullanıcı etkileşimini artırabilirsiniz.
Sürüm uyumluluğu
Bu uygulama için projenizin minSDK değerinin API düzeyi 21 veya üstü olarak ayarlanması gerekir.
Bağımlılıklar
Kaydırma tuşunu etkinleştirmek için bir düğme oluşturun
10 öğenin bulunduğu dikey bir gecikmeli listede sorunsuz kaydırma için bir düğme oluşturmak üzere aşağıdaki kodu kullanın:
Birleştirilebilir işlevlerin, Materyal Tasarım tasarım sistemine dayalı güzel kullanıcı arayüzü bileşenleri oluşturmanızı nasıl kolaylaştırabileceğini öğrenin.
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-02-06 UTC.
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-02-06 UTC."],[],[],null,["\u003cbr /\u003e\n\nYou can display a button to let a user snap scroll to a specific point in a\nlist, saving time and increasing user engagement.\n\nVersion compatibility\n\nThis implementation requires that your project minSDK be set to API level 21 or\nhigher.\n\nDependencies\n\nCreate a button to enable snap scrolling\n\nUse the following code to create a button for smooth snap scrolling in a\nvertical lazy list with 10 items:\n\n\n```kotlin\n@Composable\nfun MessageList(modifier: Modifier = Modifier) {\n val listState = rememberLazyListState()\n val coroutineScope = rememberCoroutineScope()\n\n LazyColumn(state = listState, modifier = Modifier.height(120.dp)) {\n items(10) { index -\u003e\n Text(\n modifier = Modifier.height(40.dp),\n text = \"Item $index\"\n )\n }\n }\n\n Button(onClick = {\n coroutineScope.launch {\n listState.animateScrollToItem(index = 0)\n }\n }) {\n Text(text = \"Go top\")\n }\n}https://github.com/android/snippets/blob/7a0ebbee11495f628cf9d574f6b6069c2867232a/compose/snippets/src/main/java/com/example/compose/snippets/lists/LazyListSnippets.kt#L810-L831\n```\n\n\u003cbr /\u003e\n\nKey points about the code\n\n- Uses the [`listState`](/reference/kotlin/androidx/compose/foundation/lazy/LazyListState) object to remember the scroll state of [`LazyColumn`](/reference/kotlin/androidx/compose/foundation/lazy/package-summary#LazyColumn(androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.LazyListState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,kotlin.Function1)) to the selected position.\n- Launches a coroutine to call [`listState.animateScrollToItem`](/reference/kotlin/androidx/compose/foundation/lazy/LazyListState#animateScrollToItem(kotlin.Int,kotlin.Int)), which scrolls to the indexed item while animating the scrolling action.\n\nResults **Figure 1.** A vertical scrolling list with a snap scroll button.\n\nCollections that contain this guide\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\nDisplay a list or grid \nLists and grids allow your app to display collections in a visually pleasing form that's easy for users to consume. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-a-list-or-grid) \n\nDisplay interactive components \nLearn how composable functions can enable you to easily create beautiful UI components based on the Material Design design system. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-interactive-components) \n\nCompose basics (video collection) \nThis series of videos introduces various Compose APIs, quickly showing you what's available and how to use them. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/compose-basics) \n\nHave questions or feedback \nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]