القوائم التي تتضمن ميزة "الكتابة" على نظام التشغيل Wear OS
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتيح القوائم للمستخدمين اختيار عنصر من مجموعة خيارات على أجهزة Wear OS.
تستخدم العديد من أجهزة Wear OS شاشات دائرية، ما يصعّب رؤية عناصر القائمة التي تظهر بالقرب من أعلى الشاشة وأسفلها. لهذا السبب، يتضمّن Compose for Wear OS إصدارًا من الفئة LazyColumn باسم TransformingLazyColumn، ويتيح هذا الإصدار تغيير الحجم والرسوم المتحركة التي تتضمّن تغيير الشكل.
عندما تنتقل العناصر إلى الحواف، تصبح أصغر حجمًا وتتلاشى.
لإضافة تأثير تغيير الحجم والتمرير، استخدِم Modifier.transformedHeight
للسماح لـ Compose باحتساب التغيير في الارتفاع أثناء تمرير العنصر على الشاشة، واستخدِم transformation = SurfaceTransformation(transformationSpec) لتطبيق التأثيرات المرئية، بما في ذلك تصغير حجم العنصر بصريًا ليتطابق مع العنصر السابق.
استخدِم TransformationSpec مخصّصًا للمكوّنات التي لا تقبل
transformation كمَعلمة، مثل Text.
تعرض الصورة المتحركة التالية كيف يتغير حجم العنصر وشفافيته أثناء تحرّكه على الشاشة:
يوضّح مقتطف الرمز البرمجي التالي كيفية إنشاء قائمة باستخدام
التصميم TransformingLazyColumn لإنشاء محتوى
يبدو رائعًا على مجموعة متنوعة من أحجام شاشات Wear OS، على سبيل المثال، في
مقتطف الرمز البرمجي التالي، سيضيف المساحة المتروكة اللازمة إلى العنصرَين الأول والأخير
في القائمة اللذين تم ضبطهما في contentPadding من
TransformingLazyColumn. لكي يظهر مؤشر التمرير، يجب مشاركة columnState بين ScreenScaffold وTransformingLazyColumn:
valcolumnState=rememberTransformingLazyColumnState()valcontentPadding=rememberResponsiveColumnPadding(first=ColumnItemType.ListHeader,last=ColumnItemType.Button,)valtransformationSpec=rememberTransformationSpec()ScreenScaffold(scrollState=columnState,contentPadding=contentPadding){contentPadding->
TransformingLazyColumn(state=columnState,contentPadding=contentPadding){item{ListHeader(modifier=Modifier.fillMaxWidth().transformedHeight(this,transformationSpec),transformation=SurfaceTransformation(transformationSpec)){Text(text="Header")}}// ... other itemsitem{Button(modifier=Modifier.fillMaxWidth().transformedHeight(this,transformationSpec),transformation=SurfaceTransformation(transformationSpec),onClick={/* ... */},icon={Icon(imageVector=Icons.Default.Build,contentDescription="build",)},){Text(text="Build",maxLines=1,overflow=TextOverflow.Ellipsis,)}}}}
إذا كنت بحاجة إلى إضافة سلوك "التقاط وتحريك"، نقترح استخدام
ScalingLazyColumn. يساعد هذا التأثير المستخدمين في التنقّل بدقة أكبر بين العناصر في قائمة، كما يساعدهم في التنقّل بشكل أسرع في قائمة طويلة.
لإضافة هذا التأثير إلى إصدار ScalingLazyColumn في Horologist،
اضبط المَعلمة rotaryMode الخاصة بـ columnState على
RotaryWithSnap، كما هو موضّح في مقتطف الرمز التالي:
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-23 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-23 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Lists with Compose for Wear OS\n\nCompose for Wear OS Material version 2.5 3\n\n*** ** * ** ***\n\nLists let users select an item from a set of choices on Wear OS devices.\n\n\nMany Wear OS devices use round screens, which makes it more difficult to see\nlist items that appear near the top and bottom of the screen. For this reason,\nCompose for Wear OS includes a version of the `LazyColumn` class called\n[`TransformingLazyColumn`](/reference/kotlin/androidx/wear/compose/foundation/lazy/package-summary?#TransformingLazyColumn(androidx.compose.ui.Modifier,androidx.wear.compose.foundation.lazy.TransformingLazyColumnState,androidx.compose.foundation.layout.PaddingValues,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.wear.compose.foundation.rotary.RotaryScrollableBehavior,androidx.compose.foundation.OverscrollEffect,kotlin.Function1)), which supports scaling and morphing animations.\nWhen items move to the edges, they get smaller and fade out.\n\nIn order to add a scaling and scrolling effect, use `Modifier.transformedHeight`\nto allow Compose to calculate the height change as the item scrolls through the\nscreen and `transformation = SurfaceTransformation(transformationSpec)` to apply\nthe visual effects, including scaling down the item visually to match the\nprevious.\nUse a custom [`TransformationSpec`](/reference/kotlin/androidx/wear/compose/material3/lazy/TransformationSpec) for components which don't take\n`transformation` as a parameter, for example `Text`.\n\n\nThe following animation shows how an element's size and transparency changes as\nit moves along the screen:\n\nThe following code snippet shows how to create a list using [`TransformingLazyColumn`](/reference/kotlin/androidx/wear/compose/foundation/lazy/package-summary?#TransformingLazyColumn(androidx.compose.ui.Modifier,androidx.wear.compose.foundation.lazy.TransformingLazyColumnState,androidx.compose.foundation.layout.PaddingValues,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.ui.Alignment.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.wear.compose.foundation.rotary.RotaryScrollableBehavior,androidx.compose.foundation.OverscrollEffect,kotlin.Function1)) layout to create content that [looks great on a variety of Wear OS screen sizes](/training/wearables/compose/screen-size), for example in the following sample code, it will add the necessary padding to the first and last elements of the list which are set in the `contentPadding` of the `TransformingLazyColumn`. In order for the scroll indicator to be shown, share the `columnState` between the `ScreenScaffold` and the `TransformingLazyColumn`:\n\n\u003cbr /\u003e\n\n```kotlin\nval columnState = rememberTransformingLazyColumnState()\nval contentPadding = rememberResponsiveColumnPadding(\n first = ColumnItemType.ListHeader,\n last = ColumnItemType.Button,\n)\nval transformationSpec = rememberTransformationSpec()\nScreenScaffold(\n scrollState = columnState,\n contentPadding = contentPadding\n) { contentPadding -\u003e\n TransformingLazyColumn(\n state = columnState,\n contentPadding = contentPadding\n ) {\n item {\n ListHeader(\n modifier = Modifier.fillMaxWidth().transformedHeight(this, transformationSpec),\n transformation = SurfaceTransformation(transformationSpec)\n ) {\n Text(text = \"Header\")\n }\n }\n // ... other items\n item {\n Button(\n modifier = Modifier.fillMaxWidth().transformedHeight(this, transformationSpec),\n transformation = SurfaceTransformation(transformationSpec),\n onClick = { /* ... */ },\n icon = {\n Icon(\n imageVector = Icons.Default.Build,\n contentDescription = \"build\",\n )\n },\n ) {\n Text(\n text = \"Build\",\n maxLines = 1,\n overflow = TextOverflow.Ellipsis,\n )\n }\n }\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/wear/src/main/java/com/example/wear/snippets/m3/list/List.kt#L53-L96\n```\n\nAdd a snap-and-fling effect\n---------------------------\n\nIf you need to add a snap-and-fling behavior, we suggest to use `ScalingLazyColumn`. This effect helps users more precisely navigate through the items in a list while also helping them move more quickly through a long list.\n\nTo add this effect to the Horologist's version of the [`ScalingLazyColumn`](https://google.github.io/horologist/compose-layout/),\nset the `rotaryMode` parameter of `columnState` to\n[`RotaryWithSnap`](https://google.github.io/horologist/api/compose-layout/com.google.android.horologist.compose.rotaryinput/rotary-with-snap.html), as shown in the following code snippet: \n\n```kotlin\nval columnState = rememberResponsiveColumnState(\n // ...\n // ...\n rotaryMode = ScalingLazyColumnState.RotaryMode.Snap\n)\nScreenScaffold(scrollState = columnState) {\n ScalingLazyColumn(\n columnState = columnState\n ) {\n // ...\n // ...\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/wear/src/main/java/com/example/wear/snippets/list/List.kt#L72-L103\n```\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Compose for Wear OS Codelab](/codelabs/compose-for-wear-os)\n- [Lists and Grids](/develop/ui/compose/lists)\n- [Using Views in Compose](/develop/ui/compose/migrate/interoperability-apis/views-in-compose)"]]