0Pricing
Jetpack Compose Academy · บทเรียน

Composable Image

วาดทรัพยากรภาพบนหน้าจอ

Composable Image เป็นบทเรียน Jetpack Compose Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 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 Image” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “Composable Image” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Jetpack Compose Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “Composable Image”

วาดทรัพยากรภาพบนหน้าจอ คุณปฏิบัติ Jetpack Compose Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Jetpack Compose Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Jetpack Compose Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “Composable Image” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Jetpack Compose Academy นี้ได้ไหม

ได้ บทเรียน Jetpack Compose Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. Composable Image
  2. ไอคอน Material ด้วย Icon
  3. ContentScale และการครอบตัด
  4. ตัดและกำหนดรูปทรงให้ภาพ
← กลับไปที่ Jetpack Compose Academy