0Pricing
Jetpack Compose Academy · درس

‏Padding والحجم وfillMaxWidth

تحكم في المساحة داخل Composable وحولها

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

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

Meet the Modifier

A Modifier is how you adjust a Composable: its size, spacing, and decoration. You chain calls onto it, one tweak at a time. 🧩

Pass It In

Almost every Composable takes a modifier parameter. You pass it as the first thing to change about that element.

Text(
  text = "Hi",
  modifier = Modifier
)

Add Some Padding

Use padding to add empty space around a Composable. It pushes everything else away, giving your element room to breathe.

Text(
  "Hi",
  modifier = Modifier.padding(16.dp)
)

The dp Unit

Sizes use dp, density-independent pixels. They look the same on every screen, so 16.dp is consistent across phones and tablets.

Padding Per Side

You can pad each side differently. Pass horizontal and vertical, or name individual sides like start and top.

Modifier.padding(
  horizontal = 16.dp,
  vertical = 8.dp
)

Set a Fixed Size

Use size to give a Composable an exact width and height. One value makes it square; two values set each dimension.

Modifier.size(width = 120.dp, height = 48.dp)

Width and Height Alone

Need only one dimension? Use width or height on their own and let the other side wrap its content naturally.

Modifier.height(56.dp)

Fill the Width

fillMaxWidth stretches a Composable to take up all the horizontal space its parent offers. Great for full-width buttons and rows.

Modifier.fillMaxWidth()

Fill a Fraction

Pass a fraction to fill only part of the space. fillMaxWidth(0.5f) takes half the available width instead of all of it.

Modifier.fillMaxWidth(0.5f)

Fill Everything

Use fillMaxSize to expand in both directions at once. It is the shortcut for filling width and height together.

Modifier.fillMaxSize()

Chain Them Together

The real power is chaining: stack padding, size, and fill in one fluent call to shape an element exactly how you want.

Modifier
  .fillMaxWidth()
  .padding(16.dp)

Quick Check

Which modifier stretches a Composable across all the horizontal space its parent gives?

Recap

You learned to space, size, and stretch any Composable. padding adds room, size sets exact bounds, and fillMaxWidth grows to fit. ✨

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

هل درس «‏Padding والحجم وfillMaxWidth» مجاني؟

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

ماذا ستتعلم في «‏Padding والحجم وfillMaxWidth»؟

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

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

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

كم من الوقت يستغرق درس «‏Padding والحجم وfillMaxWidth»؟

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

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

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

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

  1. ‏Padding والحجم وfillMaxWidth
  2. الخلفية والحد والقص
  3. لماذا يهم ترتيب المعدّلات
  4. ‏weight وتحديد الحجم المرن
← العودة إلى Jetpack Compose Academy