התוכן הקומפוזבילי Icon
הוא דרך נוחה לצייר על המסך סמל בצבע אחד
שעומד בהנחיות של עיצוב Material Design. כדי להשתמש בתוסף Icon
, צריך לכלול
הספרייה כתיבת חומרי לימוד (או הספרייה הוספת חומר לימוד 3).
לדוגמה, אם יש לכם קובץ drawable וקטורי שרוצים לטעון עם הגדרות ברירת המחדל של Material, תוכלו להשתמש ב-composable Icon
באופן הבא:
Icon( painter = painterResource(R.drawable.baseline_directions_bus_24), contentDescription = stringResource(id = R.string.bus_content_description) )
כברירת מחדל, הרכיב הניתן לקיבוץ Icon
מופיע בצבע LocalContentColor.current
ובגודל 24.dp
. הוא גם חושף פרמטר צבע tint
(שמשתמש באותו מנגנון לגוון כפי שמתואר בקטע גוון תמונה).
התוכן הקומפוזבילי Icon
מיועד לשימוש ברכיבי סמל קטנים. מומלץ להשתמש ב-Image
composable כדי לקבל אפשרויות התאמה אישית נוספות.
ספריית הסמלים של Material כוללת גם קבוצה של Icons
מוגדרים מראש שאפשר להשתמש בהם ב-Compose בלי לייבא קובץ SVG באופן ידני. כדי לצייר את
גרסה מעוגלת של עגלת הקניות
סמל:
Icon( Icons.Rounded.ShoppingCart, contentDescription = stringResource(id = R.string.shopping_cart_content_desc) )

חשוב לציין שלא צריך להשתמש ב-Icon
כדי להציג
VectorDrawable
במסך, מתחת למכסה, Icon
משתמש
Modifier.paint(painterResource(R.drawable.ic_bus_stop)
) על מנת לצייר את Icon
מסך. מידע נוסף על כל הסמלים הזמינים זמין במסמכי העזרה בנושא סמלים.
מומלץ עבורך
משאבים בכתיבה
Jetpack Compose is Android's recommended modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.
Accessibility in Jetpack Compose
Jetpack Compose is Android's recommended modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.
התמונות בטעינה
Jetpack Compose is Android's recommended modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs.