القيود والقياسات الجوهرية
فاوض على الحجم بين العنصر الرئيسي والفرعي
القيود والقياسات الجوهرية درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Constraints Are a Size Contract
A parent passes constraints to each child: the allowed min and max width and height. The child must choose a size that fits inside them. 📏
Four Numbers Define the Box
Every Constraints object holds minWidth, maxWidth, minHeight, and maxHeight. Together they describe the range of sizes a child may pick.
constraints.minWidth
constraints.maxWidth
constraints.maxHeightBounded vs Infinite Constraints
A max can be a real number or Infinity. Scrollable parents pass infinite height so children can be as tall as they need.
Loosen Constraints to Allow Smaller
Use copy to relax constraints before measuring. Setting minWidth to zero lets a child be smaller than the parent demands.
val loose = constraints.copy(minWidth = 0, minHeight = 0)Tighten Constraints to Force a Size
Set min equal to max and you force an exact size. The child has no choice but to be exactly that big.
val fixed = Constraints.fixed(width = 200, height = 100)Children Negotiate Within Bounds
Layout is a negotiation: the parent offers bounds, the child reports a size, the parent places it. Both sides shape the final result.
Why Intrinsics Exist
Sometimes a parent needs a child's size before the real measure pass. Intrinsic measurements answer that question without committing.
Min and Max Intrinsic Width
Ask minIntrinsicWidth for the smallest width that shows content without clipping, or maxIntrinsicWidth for the natural unwrapped width.
measurable.maxIntrinsicWidth(height)A Classic Use: Equal Heights
The built-in IntrinsicSize.Min modifier uses intrinsics to make a Row's children share the tallest height, like a divider matching its neighbors.
Row(Modifier.height(IntrinsicSize.Min)) { }Intrinsics Cost an Extra Query
Intrinsic queries run extra work, so use them only when needed. Most custom layouts get by with constraints alone. ⚡
Constraints Flow Down the Tree
Constraints cascade from the root down through every parent. Mastering how to tighten and loosen them is the heart of custom layout work.
Quick Check
How do you force a child to be an exact, fixed size?
Recap: Constraints & Intrinsics
Constraints set a child's allowed size range; loosen or tighten them with copy. Intrinsics peek at a size early, but cost extra and are used sparingly. ✅
الأسئلة الشائعة
هل درس «القيود والقياسات الجوهرية» مجاني؟
نعم — نص درس «القيود والقياسات الجوهرية» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- نموذج القياس والوضع
- كتابة Composable للتخطيط
- القيود والقياسات الجوهرية
- FlowRow يلتف حول الشرائح