خلايا الشبكة المتكيفة مقابل الثابتة
اجعل الشبكات متجاوبة مع عرض الشاشة
خلايا الشبكة المتكيفة مقابل الثابتة درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Two Ways to Size Cells
A grid needs to know how wide its columns are. Compose offers two strategies: Fixed column counts and Adaptive minimum widths. 📐
Fixed Recap
You already met GridCells.Fixed(n). It always shows n columns, so cells grow or shrink to fit the screen width.
columns = GridCells.Fixed(3)The Problem With Fixed
On a phone, 3 columns look great. On a tablet, those same 3 columns become awkwardly wide. Fixed does not adapt to bigger screens.
Enter Adaptive
With GridCells.Adaptive(minSize), you specify a minimum cell width. Compose fits as many columns as possible, then stretches them to fill.
columns = GridCells.Adaptive(minSize = 120.dp)How Adaptive Counts
Compose divides the available width by your minSize to decide the column count. A wider screen simply gets more columns, automatically.
Responsive by Default
Adaptive grids look right on phones, foldables, and tablets without any extra code. One minSize value handles every screen. 📱
Choosing a minSize
Pick a minSize that keeps content readable at its smallest. Too tiny and cells feel cramped; too large and small phones show one column.
GridCells.Adaptive(minSize = 96.dp)When Fixed Still Wins
Use Fixed when the design demands an exact count, like a 7-day calendar week that must always be 7 columns wide.
GridCells.Fixed(7)Mixing With Spacing
Both strategies pair with arrangements. The minSize in Adaptive is measured before spacing, so leave room for your gaps.
LazyVerticalGrid(
columns = GridCells.Adaptive(120.dp),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) { }LazyHorizontalGrid Too
The same Fixed and Adaptive cells work in LazyHorizontalGrid, which scrolls sideways and fills rows top to bottom.
LazyHorizontalGrid(rows = GridCells.Adaptive(80.dp)) { }A Simple Rule
Default to Adaptive for content galleries so they scale across devices. Reserve Fixed for layouts that need a precise, meaningful column count.
Quick Check
Pick the responsive choice.
Recap: Sizing Cells
You compared Fixed exact counts with Adaptive minimum widths. Adaptive scales across devices; Fixed locks an intentional column count. 🎯
الأسئلة الشائعة
هل درس «خلايا الشبكة المتكيفة مقابل الثابتة» مجاني؟
نعم — نص درس «خلايا الشبكة المتكيفة مقابل الثابتة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Jetpack Compose Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
ماذا ستتعلم في «خلايا الشبكة المتكيفة مقابل الثابتة»؟
اجعل الشبكات متجاوبة مع عرض الشاشة تتمرن على Jetpack Compose Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Jetpack Compose Academy؟
لا تُشترط خبرة سابقة. Jetpack Compose Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.
كم من الوقت يستغرق درس «خلايا الشبكة المتكيفة مقابل الثابتة»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Jetpack Compose Academy هذا؟
نعم. كل درس في Jetpack Compose Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- معارض LazyVerticalGrid
- LazyRow للتنقل الدائري
- خلايا الشبكة المتكيفة مقابل الثابتة
- حالة التمرير والتمرير البرمجي