0Pricing
Jetpack Compose Academy · درس

الخلفية والحد والقص

أضف الألوان والحدود والأشكال المستديرة

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

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

Decorate with Modifiers

Beyond sizing, modifiers can decorate a Composable. You can paint a background, draw a border, and round its corners. 🎨

Add a Background

background fills a Composable with a solid color. It paints the whole area the element occupies, including its size and fill.

Modifier.background(Color.Blue)

Use Theme Colors

Prefer theme colors over raw values. Pulling from MaterialTheme keeps your app consistent in light and dark mode.

Modifier.background(
  MaterialTheme.colorScheme.primary
)

Draw a Border

Use border to outline a Composable. Give it a thickness in dp and a color, and Compose draws the edge for you.

Modifier.border(2.dp, Color.Gray)

Meet Shapes

A Shape describes an outline like rounded or circular. Both background and border accept a shape to change their silhouette.

Rounded Corners

RoundedCornerShape softens corners by a radius in dp. It is the go-to shape for cards, buttons, and chips.

RoundedCornerShape(12.dp)

Shaped Background

Pass a shape to background and the color fills only inside that outline, giving you a tidy rounded panel.

Modifier.background(
  Color.LightGray,
  RoundedCornerShape(12.dp)
)

Clip the Content

clip trims anything drawn outside a shape. Use it so images and children respect your rounded corners.

Modifier.clip(RoundedCornerShape(12.dp))

Make a Circle

Reach for CircleShape when you want a perfect circle, like a round avatar or a floating button.

Modifier.clip(CircleShape)

Clip Before Drawing

Place clip before background so the fill is also rounded. Order in the chain decides what gets clipped.

Modifier
  .clip(RoundedCornerShape(12.dp))
  .background(Color.Cyan)

Combine for a Card

Stack clip, background, and border together to craft a polished card surface in just a few lines.

Modifier
  .clip(RoundedCornerShape(16.dp))
  .background(Color.White)
  .border(1.dp, Color.LightGray)

Quick Check

You want a rounded background where the fill itself is also rounded. Which modifier ensures that?

Recap

You can now style any element: background paints it, border outlines it, and clip with a Shape rounds it. 🎉

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

هل درس «الخلفية والحد والقص» مجاني؟

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

ماذا ستتعلم في «الخلفية والحد والقص»؟

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

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

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

كم من الوقت يستغرق درس «الخلفية والحد والقص»؟

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

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

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

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

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