{"id":37085,"date":"2024-11-01T09:54:44","date_gmt":"2024-11-01T09:54:44","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37085"},"modified":"2024-11-01T11:42:18","modified_gmt":"2024-11-01T11:42:18","slug":"course-on-kotlin-android-app-development-expanded-floating-action-button","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37085\/","title":{"rendered":"course on Kotlin Android app development, expanded floating action button"},"content":{"rendered":"<p>Hello! In this tutorial, we will delve deeply into the Extended Floating Action Button (EFAB) in Android app development using Kotlin. The Floating Action Button is a useful UI element for showing and highlighting key actions to the user. However, the Extended Floating Action Button expands this functionality to support multiple actions. The Floating Action Button is part of Material Design and is commonly used in modern app design.<\/p>\n<h2>1. What is a Floating Action Button?<\/h2>\n<p>A Floating Action Button (FAB) is a button that floats over the content on the screen. It visually emphasizes the main actions that users can perform. It is typically circular and provides quick accessibility to perform primary tasks. According to the Material Design guidelines in Android, it is positioned at the center of the user interface and fixed at the bottom of the screen.<\/p>\n<h3>1.1 Example of a Standard Floating Action Button<\/h3>\n<p>A simple example of a standard Floating Action Button could be implementing a simple note-taking app that allows users to add a button for writing a new note. The code below is an example of using a basic Floating Action Button.<\/p>\n<pre><code>class MainActivity : AppCompatActivity() {\n    private lateinit var floatingActionButton: FloatingActionButton\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n\n        floatingActionButton = findViewById(R.id.fab)\n        floatingActionButton.setOnClickListener {\n            \/\/ Action on click\n            Toast.makeText(this, \"Create a new note\", Toast.LENGTH_SHORT).show()\n        }\n    }\n}<\/code><\/pre>\n<h2>2. Extended Floating Action Button<\/h2>\n<p>The Extended Floating Action Button is a button that helps users explore more options beyond performing a primary action with a simple click. This button typically displays several actions or represents sub-menu items. It provides users with more choices, enhancing the accessibility and usability of the interface.<\/p>\n<h3>2.1 Components<\/h3>\n<p>The Extended Floating Action Button takes the form of several small buttons grouped together. Each button provides an option for the user to select. To implement this, you should also adjust Visibility and Animation to offer a smooth and intuitive user experience.<\/p>\n<h2>3. Implementation<\/h2>\n<p>Now, let&#8217;s implement the Extended Floating Action Button using Kotlin. This example will be a note-taking app where users can add new notes and display a list of notes.<\/p>\n<h3>3.1 Layout Configuration<\/h3>\n<p>First, let&#8217;s configure the XML layout file. Below is the content of the activity_main.xml file.<\/p>\n<pre><code>&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"\n    xmlns:tools=\"http:\/\/schemas.android.com\/tools\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    tools:context=\".MainActivity\"&gt;\n\n    &lt;TextView\n        android:id=\"@+id\/text_view\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"Note List\"\n        android:textSize=\"20sp\"\n        android:layout_centerInParent=\"true\"\/&gt;\n\n    &lt;com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton\n        android:id=\"@+id\/extended_fab\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_alignParentEnd=\"true\"\n        android:layout_alignParentBottom=\"true\"\n        android:layout_margin=\"16dp\"\n        android:text=\"Add\"\n        app:icon=\"@drawable\/ic_add\"\/&gt;\n\n&lt;\/RelativeLayout&gt;<\/code><\/pre>\n<h3>3.2 Activity Structure<\/h3>\n<p>Next, let&#8217;s write the MainActivity.kt file. Here, we will dynamically add buttons for the sub-actions and define the actions when these buttons are clicked.<\/p>\n<pre><code>class MainActivity : AppCompatActivity() {\n    private lateinit var extendedFAB: ExtendedFloatingActionButton\n    private lateinit var fabMenu: MutableList<floatingactionbutton>\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n\n        extendedFAB = findViewById(R.id.extended_fab)\n\n        \/\/ Initialize the list of extended menu buttons\n        fabMenu = mutableListOf()\n\n        \/\/ Add action buttons\n        createFABs()\n\n        extendedFAB.setOnClickListener {\n            toggleMenu()\n        }\n    }\n\n    private fun createFABs() {\n        \/\/ Create FABs\n        val actionButtons = listOf(\"Add Note\", \"Settings\", \"Help\")\n\n        for (action in actionButtons) {\n            val fab = FloatingActionButton(this)\n            fab.text = action\n            fab.setOnClickListener { handleActionButtonClick(action) }\n            fabMenu.add(fab)\n            (findViewById<relativelayout>(R.id.main_layout)).addView(fab)\n        }\n    }\n\n    private fun toggleMenu() {\n        for (fab in fabMenu) {\n            fab.visibility = if (fab.visibility == View.VISIBLE) View.GONE else View.VISIBLE\n        }\n    }\n\n    private fun handleActionButtonClick(action: String) {\n        Toast.makeText(this, \"$action clicked!\", Toast.LENGTH_SHORT).show()\n        toggleMenu() \/\/ Close the menu\n    }\n}<\/relativelayout><\/floatingactionbutton><\/code><\/pre>\n<h3>3.3 Screen Transition Animation<\/h3>\n<p>When using the Extended Floating Action Button, you can enhance user experience by adding animation effects. You can add animations for when the buttons appear and disappear. Below is an example with a simple animation added.<\/p>\n<pre><code>private fun toggleMenu() {\n    for (fab in fabMenu) {\n        if (fab.visibility == View.VISIBLE) {\n            fab.animate().translationY(0f).alpha(0f).setDuration(300).withEndAction {\n                fab.visibility = View.GONE\n            }\n        } else {\n            fab.visibility = View.VISIBLE\n            fab.alpha = 0f\n            fab.animate().translationY(-100f).alpha(1f).setDuration(300)\n        }\n    }\n}<\/code><\/pre>\n<h2>4. User Experience and Interface<\/h2>\n<p>From a UI\/UX perspective, the Extended Floating Action Button provides a very easy-to-use and intuitive interface. Since users can click the button to select various actions, it can be effectively utilized in apps that offer multiple features. If implemented considering both efficiency and aesthetics, users can have a simpler and more effective experience.<\/p>\n<h2>5. Conclusion<\/h2>\n<p>In this tutorial, we discussed how to implement the Extended Floating Action Button using Kotlin. Compared to the standard Floating Action Button, the Extended Floating Action Button provides users with a variety of options. Such UI components offer a better user experience and support performing intended tasks more efficiently.<\/p>\n<p>The most important aspect of Android app development is user experience. It is the developer&#8217;s role to provide the best experience to users by appropriately utilizing various UI components to ensure responsive and open design. Continue to learn and apply Kotlin to create great apps.<\/p>\n<p>Thank you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello! In this tutorial, we will delve deeply into the Extended Floating Action Button (EFAB) in Android app development using Kotlin. The Floating Action Button is a useful UI element for showing and highlighting key actions to the user. However, the Extended Floating Action Button expands this functionality to support multiple actions. The Floating Action &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37085\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;course on Kotlin Android app development, expanded floating action button&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[143],"tags":[],"class_list":["post-37085","post","type-post","status-publish","format-standard","hentry","category-kotlin-android-app-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>course on Kotlin Android app development, expanded floating action button - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/37085\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"course on Kotlin Android app development, expanded floating action button - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Hello! In this tutorial, we will delve deeply into the Extended Floating Action Button (EFAB) in Android app development using Kotlin. The Floating Action Button is a useful UI element for showing and highlighting key actions to the user. However, the Extended Floating Action Button expands this functionality to support multiple actions. The Floating Action &hellip; \ub354 \ubcf4\uae30 &quot;course on Kotlin Android app development, expanded floating action button&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37085\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:54:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:42:18+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37085\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37085\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"course on Kotlin Android app development, expanded floating action button\",\"datePublished\":\"2024-11-01T09:54:44+00:00\",\"dateModified\":\"2024-11-01T11:42:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37085\/\"},\"wordCount\":565,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"Kotlin Android app development\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37085\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37085\/\",\"name\":\"course on Kotlin Android app development, expanded floating action button - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:54:44+00:00\",\"dateModified\":\"2024-11-01T11:42:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37085\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37085\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37085\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"course on Kotlin Android app development, expanded floating action button\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"course on Kotlin Android app development, expanded floating action button - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/37085\/","og_locale":"ko_KR","og_type":"article","og_title":"course on Kotlin Android app development, expanded floating action button - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Hello! In this tutorial, we will delve deeply into the Extended Floating Action Button (EFAB) in Android app development using Kotlin. The Floating Action Button is a useful UI element for showing and highlighting key actions to the user. However, the Extended Floating Action Button expands this functionality to support multiple actions. The Floating Action &hellip; \ub354 \ubcf4\uae30 \"course on Kotlin Android app development, expanded floating action button\"","og_url":"https:\/\/atmokpo.com\/w\/37085\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:54:44+00:00","article_modified_time":"2024-11-01T11:42:18+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37085\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37085\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"course on Kotlin Android app development, expanded floating action button","datePublished":"2024-11-01T09:54:44+00:00","dateModified":"2024-11-01T11:42:18+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37085\/"},"wordCount":565,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["Kotlin Android app development"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37085\/","url":"https:\/\/atmokpo.com\/w\/37085\/","name":"course on Kotlin Android app development, expanded floating action button - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:54:44+00:00","dateModified":"2024-11-01T11:42:18+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37085\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37085\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37085\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"course on Kotlin Android app development, expanded floating action button"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37085","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=37085"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37085\/revisions"}],"predecessor-version":[{"id":37086,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37085\/revisions\/37086"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37085"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37085"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37085"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}