ไอคอน Material ด้วย Icon
ใช้ชุดไอคอนในตัวได้ทุกที่
ไอคอน Material ด้วย Icon เป็นบทเรียน Jetpack Compose Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Jetpack Compose Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Meet the Icon Composable
For small symbols like a heart or a back arrow, Compose gives you Icon. It is lighter than Image and tints itself to your theme.
A Library of Icons
You get hundreds of ready-made symbols from Icons, the Material icon set. No drawing, no exporting, just reference one by name.
Icon(imageVector = Icons.Default.Favorite, contentDescription = "Like")imageVector Is the Symbol
Icon takes an imageVector, a vector graphic from the Material set. Because it is a vector, it stays crisp at any size.
Five Visual Styles
Each symbol comes in styles: Default, Outlined, Rounded, Sharp, and TwoTone. Pick the one that matches your app personality.
Icon(Icons.Outlined.Settings, contentDescription = "Settings")Extended Icon Pack
The base set is small to keep apps lean. Add the material-icons-extended dependency to unlock thousands more symbols.
Icons Tint Automatically
By default an Icon paints itself with the current content color from your theme, so it always looks consistent without you setting a color.
Override the Tint
Want a custom color? Pass a tint argument and the symbol repaints in exactly that shade.
Icon(Icons.Default.Star, contentDescription = null, tint = Color.Yellow)Sizing an Icon
Icons render at 24dp by default, the Material standard. Change it with a Modifier.size just like any other composable.
Icon(Icons.Default.Home, contentDescription = null, modifier = Modifier.size(32.dp))Describe It Too
Like Image, Icon needs a contentDescription. Describe its action, such as "Add to favorites", or pass null if a nearby label already explains it.
Icons Inside Buttons
Icons shine inside other composables. Dropping an Icon into an IconButton gives you a tappable, perfectly sized action.
IconButton(onClick = {}) { Icon(Icons.Default.Delete, "Delete") }Icon from a Drawable
You can also build an Icon from your own asset using painterResource instead of imageVector, keeping the same automatic tinting.
Quick Check
What is the default color an Icon uses when you do not set a tint?
Recap: Material Icons
You now use Icon for crisp vector symbols, choose a style, override the tint, and size with a modifier. Next: scaling images! 🎯
คำถามที่พบบ่อย
บทเรียน “ไอคอน Material ด้วย Icon” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ไอคอน Material ด้วย Icon” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Jetpack Compose Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Jetpack Compose Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ไอคอน Material ด้วย Icon”
ใช้ชุดไอคอนในตัวได้ทุกที่ คุณปฏิบัติ Jetpack Compose Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Jetpack Compose Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Jetpack Compose Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “ไอคอน Material ด้วย Icon” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Jetpack Compose Academy นี้ได้ไหม
ได้ บทเรียน Jetpack Compose Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- Composable Image
- ไอคอน Material ด้วย Icon
- ContentScale และการครอบตัด
- ตัดและกำหนดรูปทรงให้ภาพ