0Pricing
Jetpack Compose Academy · درس

التوزيع والمحاذاة

حدّد مواضع العناصر الفرعية ومسافاتها بدقة

التوزيع والمحاذاة درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Two Words, Two Jobs

Layout control comes down to arrangement and alignment. They sound similar but they do different jobs. Let's untangle them. 🧭

Arrangement: Along the Main Axis

Arrangement controls spacing along the layout's main axis: vertical for a Column, horizontal for a Row.

Alignment: Across the Cross Axis

Alignment controls position on the other axis: horizontal in a Column, vertical in a Row. It lines children up sideways.

Grouping at One End

Arrangement.Top, Center, and Bottom pack children together at one end of a Column, leaving the rest as empty space.

Column(verticalArrangement = Arrangement.Center) {
    Text("A")
    Text("B")
}

Spreading Children Out

Use SpaceBetween, SpaceAround, or SpaceEvenly to distribute extra space among children instead of bunching them up.

Row(horizontalArrangement = Arrangement.SpaceEvenly) {
    Text("A")
    Text("B")
    Text("C")
}

SpaceBetween vs SpaceEvenly

SpaceBetween hugs the edges with no outer gaps, while SpaceEvenly adds equal gaps everywhere, including before the first and after the last child.

Fixed Gaps with spacedBy

For a consistent gap, use Arrangement.spacedBy. It inserts the exact distance you give between every adjacent child.

Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
    Text("A")
    Text("B")
}

Column's Cross-Axis Alignment

In a Column the cross axis is horizontal, so horizontalAlignment chooses Start, CenterHorizontally, or End for the children.

Column(horizontalAlignment = Alignment.End) {
    Text("Right side")
}

Row's Cross-Axis Alignment

In a Row the cross axis is vertical, so verticalAlignment picks Top, CenterVertically, or Bottom for the children.

Row(verticalAlignment = Alignment.Bottom) {
    Text("Aligned bottom")
}

Combine Both for Layout

You usually set both at once: arrangement spaces children along the main axis while alignment positions them on the cross axis.

Column(
    verticalArrangement = Arrangement.Center,
    horizontalAlignment = Alignment.CenterHorizontally
) { Text("Dead center") }

Effect Needs Extra Space

Arrangement only shows when the container is bigger than its children. A wrap-content Column has no spare room to redistribute.

Quick Check

Let's confirm which axis each setting controls.

Recap: Arrangement & Alignment

You learned the split: arrangement spaces children along the main axis, alignment positions them on the cross axis. Combine both for precise layouts.

الأسئلة الشائعة

هل درس «التوزيع والمحاذاة» مجاني؟

نعم — نص درس «التوزيع والمحاذاة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Jetpack Compose Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.

ماذا ستتعلم في «التوزيع والمحاذاة»؟

حدّد مواضع العناصر الفرعية ومسافاتها بدقة تتمرن على Jetpack Compose Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Jetpack Compose Academy؟

لا تُشترط خبرة سابقة. Jetpack Compose Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «التوزيع والمحاذاة»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Jetpack Compose Academy هذا؟

نعم. كل درس في Jetpack Compose Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. ‏Column: ترتيب العناصر رأسيًا
  2. ‏Row: وضع العناصر جنبًا إلى جنب
  3. ‏Box: التكديس والتداخل
  4. التوزيع والمحاذاة
← العودة إلى Jetpack Compose Academy