Composable الصورة
اعرض موردًا رسوميًا على الشاشة
Composable الصورة درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Pictures, the Compose Way
Every app shows pictures, and in Compose you draw them with the Image composable. It is the declarative replacement for the old ImageView. 🖼️
You Need a Painter
Image does not take a raw resource id. It takes a painter, a small object that knows how to draw your picture onto the screen.
painterResource Loads Drawables
To turn a drawable in res into a painter, you call painterResource with its resource id. This reads your PNG or vector asset.
val logo = painterResource(id = R.drawable.logo)Your First Image
Pass that painter to Image and it appears on screen. This single line draws your drawable wherever the composable sits.
Image(painter = painterResource(R.drawable.logo), contentDescription = null)contentDescription Is Required
Image always asks for a contentDescription. Screen readers speak it aloud, so describe the picture in a few clear words.
Image(painter = logo, contentDescription = "Company logo")Decorative? Pass null
If a picture is purely decorative and adds no meaning, set contentDescription to null so TalkBack skips it instead of reading noise.
Vectors Scale Cleanly
Compose loves vector drawables. A vector stays razor sharp at any size because it is math, not fixed pixels, so it never looks blurry.
Size It with a Modifier
An Image draws at the bitmap size by default. Add a Modifier.size to make it exactly the dimensions your layout needs.
Image(painter = logo, contentDescription = null, modifier = Modifier.size(96.dp))Bitmaps from the Network
painterResource only handles local assets. For remote URLs you reach for a loader library, the most popular being Coil with rememberAsyncImagePainter.
Tinting an Image
You can recolor a simple image with a colorFilter. This is great for monochrome icons you want to match your theme color.
Image(painter = logo, contentDescription = null,
colorFilter = ColorFilter.tint(Color.Blue))Image vs Icon
Use Image for photos and rich artwork. For small, theme-tinted symbols, the lighter Icon composable is usually the better choice.
Quick Check
Which argument does the Image composable always require alongside the painter?
Recap: Drawing Images
You learned that Image draws a painter from painterResource, always needs a contentDescription, and sizes with a modifier. Next up: Material icons! ✨
الأسئلة الشائعة
هل درس «Composable الصورة» مجاني؟
نعم — نص درس «Composable الصورة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Jetpack Compose Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
ماذا ستتعلم في «Composable الصورة»؟
اعرض موردًا رسوميًا على الشاشة تتمرن على Jetpack Compose Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Jetpack Compose Academy؟
لا تُشترط خبرة سابقة. Jetpack Compose Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «Composable الصورة»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Jetpack Compose Academy هذا؟
نعم. كل درس في Jetpack Compose Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- Composable الصورة
- أيقونات Material باستخدام Icon
- ContentScale والقص
- قصّ صورك وشكّلها