لماذا يهم ترتيب المعدّلات
شاهد كيف يغيّر ترتيب السلسلة النتيجة
لماذا يهم ترتيب المعدّلات درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Order Is Not Random
A modifier chain runs top to bottom. Each call wraps the result of the one before it, so the sequence truly changes the outcome.
Think in Layers
Picture each modifier as a layer stacked around your content. The first call is the innermost; later calls wrap further out.
Padding Then Background
Put padding first and the background only paints inside that inset, leaving a clear margin of unpainted space.
Modifier
.padding(16.dp)
.background(Color.Blue)Background Then Padding
Flip it: put background first and the color fills the full area, while padding then insets the content within it.
Modifier
.background(Color.Blue)
.padding(16.dp)Same Calls, Different Look
Both chains use padding and background, yet they look completely different. The only thing that changed was the order.
Size Affects Followers
A size call sets bounds for everything after it. Modifiers placed before size measure differently than ones placed after.
Modifier
.size(100.dp)
.background(Color.Red)Clip Then Background
Place clip before background so the fill is rounded. After background, the clip would not affect the already-painted color.
Modifier
.clip(RoundedCornerShape(12.dp))
.background(Color.Green)clickable Reach
Where you place clickable sets the tappable area. Padding before it shrinks the hit target; padding after it stays inside.
Modifier
.clickable { open() }
.padding(16.dp)Read It Outward
To predict the result, read the chain inside out. The earliest modifier hugs the content; each later one wraps around it.
A Handy Rule
Want spacing outside a colored box? Background first, then padding. Want a margin? Padding first. Order is your design tool.
Experiment Freely
When a layout looks off, try reordering the chain. Swapping two modifiers often fixes spacing and shape surprises instantly.
Quick Check
You want a colored box with empty space inside, around its text. Which order do you use?
Recap
Modifier order decides the result. Read chains inside out, and remember background-then-padding pads inside the color. 🧠
الأسئلة الشائعة
هل درس «لماذا يهم ترتيب المعدّلات» مجاني؟
نعم — نص درس «لماذا يهم ترتيب المعدّلات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- Padding والحجم وfillMaxWidth
- الخلفية والحد والقص
- لماذا يهم ترتيب المعدّلات
- weight وتحديد الحجم المرن