संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
Compose को आज़माएं
Android के लिए, Jetpack Compose को यूज़र इंटरफ़ेस (यूआई) टूलकिट के तौर पर इस्तेमाल करने का सुझाव दिया जाता है. Compose में कॉम्पोनेंट जोड़ने का तरीका जानें.
फ़्लोटिंग ऐक्शन बटन (एफ़एबी), गोल आकार का एक बटन होता है. यह आपके ऐप्लिकेशन के यूज़र इंटरफ़ेस (यूआई) में मुख्य कार्रवाई को ट्रिगर करता है. इस दस्तावेज़ में, लेआउट में FAB जोड़ने, उसकी कुछ स्टाइल को पसंद के मुताबिक बनाने, और बटन टैप पर जवाब देने का तरीका बताया गया है.
Material Design के दिशा-निर्देशों के मुताबिक, अपने ऐप्लिकेशन के लिए FAB डिज़ाइन करने के बारे में ज़्यादा जानने के लिए, Material Design FAB देखें
.
पहली इमेज. फ़्लोटिंग ऐक्शन बटन (एफ़एबी).
अपने लेआउट में फ़्लोटिंग ऐक्शन बटन जोड़ना
यहां दिए गए कोड में दिखाया गया है कि आपकी लेआउट फ़ाइल में FloatingActionButton कैसा दिखता है:
एक्सएमएल एट्रिब्यूट या उनसे जुड़े तरीकों का इस्तेमाल करके, अन्य FAB प्रॉपर्टी कॉन्फ़िगर की जा सकती हैं. जैसे:
app:fabSize एट्रिब्यूट या setSize() तरीके का इस्तेमाल करके, FAB का साइज़
app:rippleColor एट्रिब्यूट या setRippleColor() तरीके का इस्तेमाल करके, FAB के रिपल का रंग
android:src एट्रिब्यूट या setImageDrawable() तरीके का इस्तेमाल करके, FAB आइकॉन
बटन टैप करने पर जवाब देना
इसके बाद, FAB टैप को हैंडल करने के लिए, View.OnClickListener लागू किया जा सकता है. उदाहरण के लिए, यहां दिया गया कोड, उपयोगकर्ता के FAB पर टैप करने पर Snackbar दिखाता है:
Kotlin
valfab:View=findViewById(R.id.fab)fab.setOnClickListener{view->Snackbar.make(view,"Here's a Snackbar",Snackbar.LENGTH_LONG).setAction("Action",null).show()}
Java
FloatingActionButtonfab=findViewById(R.id.fab);fab.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewview){Snackbar.make(view,"Here's a Snackbar",Snackbar.LENGTH_LONG).setAction("Action",null).show();}});
एफ़एबी की सुविधाओं के बारे में ज़्यादा जानने के लिए, FloatingActionButton के लिए एपीआई रेफ़रंस देखें.
इस पेज पर मौजूद कॉन्टेंट और कोड सैंपल कॉन्टेंट के लाइसेंस में बताए गए लाइसेंस के हिसाब से हैं. Java और OpenJDK, Oracle और/या इससे जुड़ी हुई कंपनियों के ट्रेडमार्क या रजिस्टर किए हुए ट्रेडमार्क हैं.
आखिरी बार 2025-08-27 (UTC) को अपडेट किया गया.
[[["समझने में आसान है","easyToUnderstand","thumb-up"],["मेरी समस्या हल हो गई","solvedMyProblem","thumb-up"],["अन्य","otherUp","thumb-up"]],[["वह जानकारी मौजूद नहीं है जो मुझे चाहिए","missingTheInformationINeed","thumb-down"],["बहुत मुश्किल है / बहुत सारे चरण हैं","tooComplicatedTooManySteps","thumb-down"],["पुराना","outOfDate","thumb-down"],["अनुवाद से जुड़ी समस्या","translationIssue","thumb-down"],["सैंपल / कोड से जुड़ी समस्या","samplesCodeIssue","thumb-down"],["अन्य","otherDown","thumb-down"]],["आखिरी बार 2025-08-27 (UTC) को अपडेट किया गया."],[],[],null,["Try the Compose way \nJetpack Compose is the recommended UI toolkit for Android. Learn how to add components in Compose. \n[Floating Action Button →](/develop/ui/compose/components/fab) \n\n\u003cbr /\u003e\n\nA floating action button (FAB) is a circular button that triggers the primary\naction in your app's UI. This document shows how to add a FAB to your layout,\ncustomize some of its appearance, and respond to button taps.\n\nTo learn more about how to design a FAB for your app according to the Material\nDesign Guidelines, see [Material Design\nFAB](https://m3.material.io/components/floating-action-button/overview)\n.\n**Figure 1.** A floating action button (FAB).\n\nAdd the floating action button to your layout\n\nThe following code shows how the\n[`FloatingActionButton`](/reference/com/google/android/material/floatingactionbutton/FloatingActionButton)\nappears in your layout file: \n\n```xml\n\u003ccom.google.android.material.floatingactionbutton.FloatingActionButton\n android:id=\"@+id/fab\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_gravity=\"end|bottom\"\n android:src=\"@drawable/ic_my_icon\"\n android:contentDescription=\"@string/submit\"\n android:layout_margin=\"16dp\" /\u003e\n```\n\nBy default, a FAB is colored by the `colorAccent` attribute, which you can\n[customize with the theme's color\npalette](/guide/topics/ui/look-and-feel/themes#ColorPalette).\n\nYou can configure other FAB properties using XML attributes or corresponding\nmethods, such as the following:\n\n- The size of the FAB, using the `app:fabSize` attribute or the [`setSize()`](/reference/com/google/android/material/floatingactionbutton/FloatingActionButton#setSize(int)) method\n- The ripple color of the FAB, using the `app:rippleColor` attribute or the [`setRippleColor()`](/reference/com/google/android/material/floatingactionbutton/FloatingActionButton#setRippleColor(int)) method\n- The FAB icon, using the `android:src` attribute or the [`setImageDrawable()`](/reference/android/widget/ImageView#setImageDrawable(android.graphics.drawable.Drawable)) method\n\nRespond to button taps\n\nYou can then apply an\n[`View.OnClickListener`](/reference/android/view/View.OnClickListener) to\nhandle FAB taps. For example, the following code displays a\n[`Snackbar`](/reference/com/google/android/material/snackbar/Snackbar) when\nthe user taps the FAB: \n\nKotlin \n\n```kotlin\nval fab: View = findViewById(R.id.fab)\nfab.setOnClickListener { view -\u003e\n Snackbar.make(view, \"Here's a Snackbar\", Snackbar.LENGTH_LONG)\n .setAction(\"Action\", null)\n .show()\n}\n```\n\nJava \n\n```java\nFloatingActionButton fab = findViewById(R.id.fab);\nfab.setOnClickListener(new View.OnClickListener() {\n @Override\n public void onClick(View view) {\n Snackbar.make(view, \"Here's a Snackbar\", Snackbar.LENGTH_LONG)\n .setAction(\"Action\", null).show();\n }\n});\n```\n\nFor more information about the capabilities of the FAB, see the API reference\nfor the\n[`FloatingActionButton`](/reference/com/google/android/material/floatingactionbutton/FloatingActionButton)."]]