تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
زر الإجراء العائم (FAB) هو زر ذو أهمية عالية يتيح للمستخدم
تنفيذ إجراء أساسي في أحد التطبيقات. ويشجّع على اتّخاذ إجراء واحد مركّز
يمثّل المسار الأكثر شيوعًا الذي قد يتّخذه المستخدم، وعادةً ما يكون
مثبّتًا في أسفل يسار الشاشة.
في ما يلي ثلاث حالات استخدام يمكنك فيها استخدام زر الإجراء العائم:
إنشاء عنصر جديد: في تطبيق لتدوين الملاحظات، يمكن استخدام زر الإجراء العائم لإنشاء ملاحظة جديدة بسرعة.
إضافة جهة اتصال جديدة: في تطبيق دردشة، يمكن أن يفتح زر الإجراء العائم واجهة تتيح للمستخدم إضافة شخص إلى محادثة.
توسيط الموقع الجغرافي: في واجهة الخريطة، يمكن أن يوسّط زر الإجراء العائم الخريطة على الموقع الجغرافي الحالي للمستخدم.
في Material Design، هناك أربعة أنواع من أزرار الإجراء العائم:
لإنشاء زر إجراء عائم صغير، استخدِم الدالة البرمجية القابلة للإنشاء
SmallFloatingActionButton. يوضّح المثال التالي كيفية إجراء ذلك، مع إضافة ألوان مخصّصة.
لإنشاء زر إجراء عائم كبير، استخدِم الدالة القابلة للإنشاء
LargeFloatingActionButton. لا يختلف هذا العنصر القابل للإنشاء بشكل كبير عن الأمثلة الأخرى باستثناء أنّه يؤدي إلى إنشاء زر أكبر.
يمكنك إنشاء أزرار إجراء عائم أكثر تعقيدًا باستخدام العنصر القابل للإنشاء ExtendedFloatingActionButton. يتمثّل الاختلاف الرئيسي بين هذا النوع وFloatingActionButton في أنّه يتضمّن مَعلمتَي icon وtext مخصّصتَين. تتيح لك هذه الأزرار إنشاء زر يتضمّن محتوًى أكثر تعقيدًا يمكن تغيير حجمه ليناسب المحتوى بشكل ملائم.
يوضّح المقتطف التالي كيفية تنفيذ
ExtendedFloatingActionButton، مع عرض قيم نموذجية تم تمريرها لكل من icon وtext.
على الرغم من توفّر العديد من العناصر القابلة للإنشاء التي يمكنك استخدامها لإنشاء أزرار إجراء عائم متوافقة مع "التصميم المتعدد الأبعاد"، لا تختلف مَعلمات هذه العناصر كثيرًا.
في ما يلي بعض المعايير الرئيسية التي يجب مراعاتها:
onClick: الدالة التي يتم استدعاؤها عندما يضغط المستخدم على الزر.
containerColor: لون الزر.
contentColor: لون الرمز.
z## المجموعات التي تتضمّن هذا الدليل
يشكّل هذا الدليل جزءًا من مجموعات "الدليل السريع" المنسّقة التي تغطي أهدافًا أوسع لتطوير تطبيقات Android:
عرض المكوّنات التفاعلية
تعرَّف على كيف يمكن أن تتيح لك الدوال البرمجية القابلة للإنشاء إنشاء مكوّنات رائعة لواجهة المستخدم بسهولة استنادًا إلى نظام تصميم Material Design.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-24 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-24 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Create a floating action button (FAB)\n\n\u003cbr /\u003e\n\nA floating action button (FAB) is a high-emphasis button that lets the user\nperform a primary action in an application. It promotes a single, focused action\nthat is the most common pathway a user might take and is typically found\nanchored to the bottom right of the screen.\n\nConsider these three use cases where you might use a FAB:\n\n- **Create new item**: In a note-taking app, a FAB might be used to quickly create a new note.\n- **Add new contact**: In a chat app, a FAB could open an interface that lets the user add someone to a conversation.\n- **Center location**: In a map interface, a FAB could center the map on the user's current location.\n\nIn Material Design, there are four types of FAB:\n\n- [FAB](#basic): A floating action button of ordinary size.\n- [Small FAB](#small): A smaller floating action button.\n- [Large FAB](#large): A larger floating action button.\n- [Extended FAB](#extended): A floating action button that contains more than just an icon.\n\nVersion compatibility\n---------------------\n\nThis implementation requires that your project minSDK be set to API level 21 or\nhigher.\n\n### Dependencies\n\n### Kotlin\n\n\n```kotlin\n implementation(platform(\"androidx.compose:compose-bom:2025.08.00\"))\n```\n\n\u003cbr /\u003e\n\n### Groovy\n\n\n```groovy\n implementation platform('androidx.compose:compose-bom:2025.08.00')\n```\n\n\u003cbr /\u003e\n\nCreate a basic floating action button\n-------------------------------------\n\nTo create a general floating action button, use the basic\n[`FloatingActionButton`](/reference/kotlin/androidx/compose/material3/package-summary#FloatingActionButton(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.material3.FloatingActionButtonElevation,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function0)) composable:\n\n\n```kotlin\n@Composable\nfun Example(onClick: () -\u003e Unit) {\n FloatingActionButton(\n onClick = { onClick() },\n ) {\n Icon(Icons.Filled.Add, \"Floating action button.\")\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/components/FloatingActionButton.kt#L61-L68\n```\n\n\u003cbr /\u003e\n\n### Result\n\n**Figure 1.** A floating action button.\n\nCreate a small floating action button\n-------------------------------------\n\nTo create a small floating action button, use the\n[`SmallFloatingActionButton`](/reference/kotlin/androidx/compose/material3/package-summary#SmallFloatingActionButton(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.material3.FloatingActionButtonElevation,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function0)) composable. The following example demonstrates\nhow to do so, with the addition of custom colors.\n\n\n```kotlin\n@Composable\nfun SmallExample(onClick: () -\u003e Unit) {\n SmallFloatingActionButton(\n onClick = { onClick() },\n containerColor = MaterialTheme.colorScheme.secondaryContainer,\n contentColor = MaterialTheme.colorScheme.secondary\n ) {\n Icon(Icons.Filled.Add, \"Small floating action button.\")\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/components/FloatingActionButton.kt#L83-L92\n```\n\n\u003cbr /\u003e\n\n| **Note:** Because the various FAB composables share many parameters, you can use the approach in this example to customize colors with other composables.\n\n### Result\n\n**Figure 2.** A small floating action button.\n\nCreate a large floating action button\n-------------------------------------\n\nTo create a large floating action button, use the\n[`LargeFloatingActionButton`](/reference/kotlin/androidx/compose/material3/package-summary#LargeFloatingActionButton(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.material3.FloatingActionButtonElevation,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function0)) composable. This composable is not\nsignificantly different from the other examples aside from the fact that it\nresults in a bigger button.\n\nThe following is a straightforward implementation of a large FAB.\n| **Note:** This example passes `CircleShape` as the value for the `shape` parameter, resulting in a round button, rather than a square with rounded borders. You can pass any instance of `Shape`, or set the value of `MaterialTheme.shape.large` to adjust it across your app.\n\n\n```kotlin\n@Composable\nfun LargeExample(onClick: () -\u003e Unit) {\n LargeFloatingActionButton(\n onClick = { onClick() },\n shape = CircleShape,\n ) {\n Icon(Icons.Filled.Add, \"Large floating action button\")\n }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/components/FloatingActionButton.kt#L96-L104\n```\n\n\u003cbr /\u003e\n\n### Result\n\n**Figure 3.** A large floating action button.\n\nCreate an extended floating action button\n-----------------------------------------\n\nYou can create more complex floating action buttons with the\n[`ExtendedFloatingActionButton`](/reference/kotlin/androidx/compose/material3/package-summary#ExtendedFloatingActionButton(kotlin.Function0,kotlin.Function0,kotlin.Function0,androidx.compose.ui.Modifier,kotlin.Boolean,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.material3.FloatingActionButtonElevation,androidx.compose.foundation.interaction.MutableInteractionSource)) composable. The key difference between it\nand [`FloatingActionButton`](/reference/kotlin/androidx/compose/material3/package-summary#FloatingActionButton(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.ui.graphics.Shape,androidx.compose.ui.graphics.Color,androidx.compose.ui.graphics.Color,androidx.compose.material3.FloatingActionButtonElevation,androidx.compose.foundation.interaction.MutableInteractionSource,kotlin.Function0)) is that it has dedicated `icon` and `text`\nparameters. They let you create a button with more complex content that scales\nto fit its content appropriately.\n\nThe following snippet demonstrates how to implement\n`ExtendedFloatingActionButton`, with example values passed for `icon` and\n`text`.\n\n\n```kotlin\n@Composable\nfun ExtendedExample(onClick: () -\u003e Unit) {\n ExtendedFloatingActionButton(\n onClick = { onClick() },\n icon = { Icon(Icons.Filled.Edit, \"Extended floating action button.\") },\n text = { Text(text = \"Extended FAB\") },\n )\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/components/FloatingActionButton.kt#L72-L79\n```\n\n\u003cbr /\u003e\n\n### Result\n\n**Figure 4.** A floating action button with both text and an icon.\n\nKey points\n----------\n\nAlthough there are several composables you can use to create floating action\nbuttons consistent with Material Design, their parameters don't differ greatly.\nAmong the key parameters you should keep in mind are the following:\n\n- `onClick`: The function called when the user presses the button.\n- `containerColor`: The color of the button.\n- `contentColor`: The color of the icon.\n\nz## Collections that contain this guide\n\nThis guide is part of these curated Quick Guide collections that cover\nbroader Android development goals: \n\n### Display interactive components\n\nLearn how composable functions can enable you to easily create beautiful UI components based on the Material Design design system. \n[Quick guide collection](/develop/ui/compose/quick-guides/collections/display-interactive-components) \n\nHave questions or feedback\n--------------------------\n\nGo to our frequently asked questions page and learn about quick guides or reach out and let us know your thoughts. \n[Go to FAQ](/quick-guides/faq) [Leave feedback](https://issuetracker.google.com/issues/new?component=1573691&template=1993320)"]]