{"id":537,"date":"2020-06-03T17:46:06","date_gmt":"2020-06-03T09:46:06","guid":{"rendered":"https:\/\/badgameshow.com\/fly\/?p=537"},"modified":"2020-11-26T14:47:28","modified_gmt":"2020-11-26T06:47:28","slug":"material-design-bottom-navigation","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/fly\/material-design-bottom-navigation\/","title":{"rendered":"Material Design Bottom Navigation"},"content":{"rendered":"<p><iframe loading=\"lazy\" title=\"\u3010Android\u3011Bottom Navigation | Kotlin | Android Studio\" width=\"640\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/gh1-9UmvU_w?start=124&#038;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h3>1.\u5148\u5c0e\u5165\u51fd\u793a\u5eab(build.gradle: Module)<\/h3>\n<pre><code class=\"language-Gradle line-numbers\">dependencies {\n   implementation 'com.google.android.material:material:1.2.0-alpha05'\n}\n<\/code><\/pre>\n<h3>2.\u7a0b\u5f0f\u78bc\u7bc4\u4f8b<\/h3>\n<h4>a.\u5275\u5efamenu<\/h4>\n<pre><code class=\"language-XML line-numbers\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;menu xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\n    xmlns:app=\"http:\/\/schemas.android.com\/apk\/res-auto\"&gt;\n    &lt;item\n        android:id=\"@+id\/home\"\n        android:icon=\"@drawable\/home\"\n        android:title=\"\u9996\u9801\" \/&gt;\n    &lt;item android:title=\"\u804a\u5929\"\n        android:icon=\"@drawable\/chat\"\n        android:id=\"@+id\/chat\"\/&gt;\n    &lt;item android:title=\"\u734e\u52f5\"\n        android:icon=\"@drawable\/bonus\"\n        android:id=\"@+id\/bonus\"\/&gt;\n    &lt;item android:title=\"\u500b\u4eba\"\n        android:icon=\"@drawable\/personal\"\n        android:id=\"@+id\/personal\"\/&gt;\n&lt;\/menu&gt;\n<\/code><\/pre>\n<h4>b.layout\u8072\u660eBottomNavigationView<\/h4>\n<pre><code class=\"language-XML line-numbers\">&lt;com.google.android.material.bottomnavigation.BottomNavigationView\n        app:itemTextColor=\"@color\/colorPrimaryDark\"\n        android:background=\"@color\/colorBg\"\n        android:id=\"@+id\/bottomBar\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        app:layout_constraintBottom_toBottomOf=\"parent\"\n        app:layout_constraintEnd_toEndOf=\"parent\"\n        app:layout_constraintStart_toStartOf=\"parent\"\n        app:menu=\"@menu\/menu\" \/&gt;\n<\/code><\/pre>\n<h4>c. Bottom navigation\u8a2d\u7f6e\u76e3\u807d<\/h4>\n<pre><code class=\"language-Kotlin line-numbers\">  \/\/\u8b93bottomNavigation\u53ef\u4ee5\u986f\u793a\u539f\u5716\n  bottomBar.itemIconTintList = null\n\n  bottomBar.setOnNavigationItemSelectedListener {\n            item -&gt;\n            when(item.itemId) {\n                R.id.home -&gt; {\n                    page_name.text = item.title\n                    supportFragmentManager.beginTransaction().replace(R.id.fragment, HomeFragment.instance).commit()\n                    true\n                }\n\n                R.id.chat -&gt; {\n                    page_name.text = item.title\n                    supportFragmentManager.beginTransaction().replace(R.id.fragment, ChatFragment.instance).commit()\n                    true\n                }\n\n                R.id.bonus -&gt; {\n                    page_name.text = item.title\n                    supportFragmentManager.beginTransaction().replace(R.id.fragment, BonusFragment.instance).commit()\n                    true\n                }\n                else -&gt; {\n                    page_name.text = item.title\n                    supportFragmentManager.beginTransaction().replace(R.id.fragment, PersonalFragment.instance).commit()\n                    true\n                }\n            }\n        }\n<\/code><\/pre>\n<h3>4.\u6548\u679c\u5c55\u793a<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2020\/06\/video-1591177240.gif\" alt=\"\" \/><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>1.\u5148\u5c0e\u5165\u51fd\u793a\u5eab(build.gradle: Module) dependencies { implement &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[76],"tags":[13,110,78],"class_list":["post-537","post","type-post","status-publish","format-standard","hentry","category-material-design","tag-android","tag-bottom-navigation","tag-material-design"],"_links":{"self":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/537","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/comments?post=537"}],"version-history":[{"count":6,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/537\/revisions"}],"predecessor-version":[{"id":1002,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/537\/revisions\/1002"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/media?parent=537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/categories?post=537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/tags?post=537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}