0Pricing
Jetpack Compose Academy · درس

‏ContentScale والقص

لاءم الصور واملأها واقصصها بدقة

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

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

When Image and Box Disagree

Your image has its own aspect ratio, but your layout slot has another. ContentScale decides how the picture fits into that space.

The Aspect Ratio Problem

Force a wide photo into a square and it can stretch or squash. ContentScale gives you sane rules so pictures never look distorted by accident.

Crop Fills and Trims

The most common choice is ContentScale.Crop. It fills the whole slot and trims any overflow, so the frame is always full with no gaps.

Image(painter = p, contentDescription = null,
    contentScale = ContentScale.Crop)

Fit Shows Everything

ContentScale.Fit shrinks the image until it all fits inside the slot. Nothing is cut off, but you may see empty space on two sides.

FillBounds Can Distort

ContentScale.FillBounds stretches the image to fill both dimensions exactly. It guarantees no gaps but will warp the aspect ratio.

Width or Height Only

Need to fill just one axis? FillWidth and FillHeight scale to match that single dimension while keeping the ratio.

Inside Crops, None Does Not

Inside only shrinks when too big and never enlarges, while None draws at original size, cropping if it overflows.

Crop Needs a Bounded Size

Crop only has an effect when the Image has fixed bounds. Give it a size or fillMaxWidth with a height, or there is nothing to crop into.

Image(painter = p, contentDescription = null,
    modifier = Modifier.size(120.dp), contentScale = ContentScale.Crop)

Align Within the Frame

When Fit leaves empty space, the alignment argument decides where the image sits, such as Center or TopStart.

Image(painter = p, contentDescription = null, alignment = Alignment.TopCenter)

Crop for Thumbnails

Thumbnails and avatars almost always use Crop. It guarantees a clean, gap-free tile no matter the source photo dimensions.

Pick by Intent

Choose by what matters: use Fit when the whole image must be visible, and Crop when a full, edge-to-edge frame matters more.

Quick Check

You want an avatar tile that is always completely filled with no empty space. Which ContentScale fits best?

Recap: Scaling Images

You can now choose ContentScale wisely: Crop to fill, Fit to show all, and align the result. Next: clipping into shapes! 🔲

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

هل درس «‏ContentScale والقص» مجاني؟

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

ماذا ستتعلم في «‏ContentScale والقص»؟

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

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

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

كم من الوقت يستغرق درس «‏ContentScale والقص»؟

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

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

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

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

  1. ‏Composable الصورة
  2. أيقونات Material باستخدام Icon
  3. ‏ContentScale والقص
  4. قصّ صورك وشكّلها
← العودة إلى Jetpack Compose Academy