اللون والمحاذاة وتجاوز المساحة
لوّن النص وتعامل مع المحتوى الطويل بسلاسة
اللون والمحاذاة وتجاوز المساحة درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Beyond Black Text
Default text adopts your theme color, but you often want a specific tint. Compose lets you set color and handle long content with ease.
Tint with color
Pass a color to recolor any Text. Use Color values directly, or pull semantic colors from MaterialTheme for theme-aware results.
Text("Error", color = Color.Red)Prefer Theme Colors
Hardcoded colors break in dark mode. Reach for MaterialTheme.colorScheme so your text stays readable on every background.
Text("Hi", color = MaterialTheme.colorScheme.primary)Align the Text
Control horizontal alignment with textAlign. Center a title or justify a paragraph; it only matters when Text has width to fill.
Text("Centered", textAlign = TextAlign.Center)Alignment Needs Width
For textAlign to show, the Text must be wider than its words, usually via fillMaxWidth. Otherwise it hugs the text and nothing shifts.
Text("Hi", modifier = Modifier.fillMaxWidth(),
textAlign = TextAlign.Center)The Overflow Problem
Real data can be longer than your space. Without a plan, text may push your layout or get awkwardly clipped. Overflow handling fixes this.
Cap with maxLines
Limit height by setting maxLines. The text will draw at most that many lines and quietly stop, keeping rows a predictable size.
Text(longBio, maxLines = 2)Show an Ellipsis
Pair maxLines with overflow = TextOverflow.Ellipsis to trail off with three dots, signaling there is more to read.
Text(longBio, maxLines = 1,
overflow = TextOverflow.Ellipsis)Other Overflow Modes
TextOverflow also offers Clip, which simply cuts at the edge, and Visible, which lets text spill out. Ellipsis is the friendliest default. 🙂
Min Lines for Stability
Use minLines to reserve space so a card does not jump in height when one item has shorter text than another in a list.
Text(caption, minLines = 2, maxLines = 2)Polished, Predictable Text
Color makes meaning clear, alignment guides the eye, and overflow rules keep layouts stable no matter how long the real data gets.
Quick Check
You want a one-line label that ends with three dots when too long. What do you set?
Recap
You learned to tint text with color, position it using textAlign, and tame long content with maxLines plus overflow. Layouts stay tidy. ✨
الأسئلة الشائعة
هل درس «اللون والمحاذاة وتجاوز المساحة» مجاني؟
نعم — نص درس «اللون والمحاذاة وتجاوز المساحة» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Jetpack Compose Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.
ماذا ستتعلم في «اللون والمحاذاة وتجاوز المساحة»؟
لوّن النص وتعامل مع المحتوى الطويل بسلاسة تتمرن على Jetpack Compose Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Jetpack Compose Academy؟
لا تُشترط خبرة سابقة. Jetpack Compose Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.
كم من الوقت يستغرق درس «اللون والمحاذاة وتجاوز المساحة»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Jetpack Compose Academy هذا؟
نعم. كل درس في Jetpack Compose Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- Composable النص
- حجم الخط ووزنه ونمطه
- اللون والمحاذاة وتجاوز المساحة
- AnnotatedString: نص منسق مختلط