{"id":1671,"date":"2022-12-22T14:03:42","date_gmt":"2022-12-22T06:03:42","guid":{"rendered":"https:\/\/badgameshow.com\/fly\/?p=1671"},"modified":"2023-01-12T11:15:14","modified_gmt":"2023-01-12T03:15:14","slug":"%e3%80%90material-design%e3%80%91android-top-app-bar-%e9%a0%82%e9%83%a8%e6%87%89%e7%94%a8%e6%ac%84-%e7%af%84%e4%be%8b","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/fly\/%e3%80%90material-design%e3%80%91android-top-app-bar-%e9%a0%82%e9%83%a8%e6%87%89%e7%94%a8%e6%ac%84-%e7%af%84%e4%be%8b\/","title":{"rendered":"\u3010Material Design\u3011Android Top app bar \u9802\u90e8\u61c9\u7528\u6b04 \u7bc4\u4f8b"},"content":{"rendered":"<h1>\u3010Material Design\u3011Android Top app bar \u9802\u90e8\u61c9\u7528\u6b04 \u7bc4\u4f8b<\/h1>\n<h4>Android top app bar \u662f\u4e00\u500b\u5c08\u9580\u70ba Android \u88dd\u7f6e\u8a2d\u8a08\u7684\u61c9\u7528\u7a0b\u5f0f\u72c0\u614b\u5217\uff0c\u5b83\u5305\u542b\u4e00\u4e9b\u6309\u9215\uff0c\u6839\u64da\u4f7f\u7528\u8005\u884c\u70ba\u5b9a\u5236\u914d\u7f6e\u529f\u80fd\uff0c\u4ee5\u6eff\u8db3\u61c9\u7528\u7a0b\u5f0f\u548c\u6b61\u8fce\u4f7f\u7528\u8005\u7684\u9700\u6c42\u3002<\/h4>\n<h4>\u6b64\u9802\u90e8\u6a19\u984c\u6b04\u6703\u51fa\u73fe\u5728\u624b\u6a5f\u548c\u5e73\u677f\u96fb\u8166\u986f\u793a\u5340\u57df\u7684\u9802\u90e8\uff0c\u53ef\u63d0\u4f9b\u61c9\u7528\u7a0b\u5f0f\u5c0e\u89bd\uff0c\u5feb\u901f\u8a2a\u554f\u548c\u529f\u80fd\u6309\u9215\uff0c\u4ee5\u53ca\u91cd\u8981\u61c9\u7528\u7a0b\u5f0f\u529f\u80fd\u548c\u76f8\u95dc\u7279\u6027\u7684\u5c0e\u822a\u3002<\/h4>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/lh3.googleusercontent.com\/GuU1qgXKnmBdhqd4v_fObCdAgd7VkmfSqRw-TvPlXJR1sHFH5-tGOaeTRLiOTwK7ZAMVIDX0Zdlh0wyUNMFb-evuqvEIc6069But16ZtCqnJf5BG1D3a=w2400\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/GuU1qgXKnmBdhqd4v_fObCdAgd7VkmfSqRw-TvPlXJR1sHFH5-tGOaeTRLiOTwK7ZAMVIDX0Zdlh0wyUNMFb-evuqvEIc6069But16ZtCqnJf5BG1D3a=w2400\" alt=\"\" \/><\/a><\/p>\n<hr \/>\n<h4>\u6587\u7ae0\u76ee\u9304<\/h4>\n<ol>\n<li><a href=\"#a\">Top app bar \u6ed1\u52d5\u4e0a\u62ac\u61c9\u7528\u6b04<\/a><\/li>\n<li><a href=\"#b\">Top app bar \u6ed1\u52d5\u4e0a\u62ac\u6a19\u984c\u8207\u61c9\u7528\u6b04\u5e73\u884c<\/a><\/li>\n<li><a href=\"#c\">Top app bar \u6ed1\u52d5\u4e0a\u62ac\u6a19\u984c\u8207\u61c9\u7528\u6b04\u5e73\u884c + \u5716\u7247<\/a><\/li>\n<li><a href=\"#d\">Top app bar \u64cd\u4f5c\u6b04<\/a><\/li>\n<li><a href=\"#e\">Developer Documents Top app bar<\/a><\/li>\n<\/ol>\n<hr \/>\n<p><a id=\"a\"><\/a><\/p>\n<h4>1.Top app bar \u6ed1\u52d5\u4e0a\u62ac\u61c9\u7528\u6b04<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2022\/12\/2022-12-22_13-34-08-online-video-cutter.com_.gif\" width=\"50%\"\/><\/p>\n<h5>menu\/top_app_bar.xml<\/h5>\n<pre data-language=XML><code class=\"language-markup 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\n    &lt;item\n        android:id=\"@+id\/favorite\"\n        android:icon=\"@drawable\/ic_favorite_24dp\"\n        android:title=\"favorite\"\n        app:showAsAction=\"ifRoom\" \/&gt;\n\n    &lt;item\n        android:id=\"@+id\/search\"\n        android:icon=\"@drawable\/ic_search_24dp\"\n        android:title=\"search\"\n        app:showAsAction=\"ifRoom\" \/&gt;\n\n    &lt;item\n        android:id=\"@+id\/more\"\n        android:title=\"more\"\n        app:showAsAction=\"never\" \/&gt;\n\n&lt;\/menu&gt;\n<\/code><\/pre>\n<h5>activity_main.xml<\/h5>\n<pre data-language=XML><code class=\"language-markup line-numbers\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;layout 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\"&gt;\n\n    &lt;data&gt;\n\n    &lt;\/data&gt;\n\n    &lt;androidx.coordinatorlayout.widget.CoordinatorLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        tools:context=\".MainActivity\"&gt;\n\n        &lt;com.google.android.material.appbar.AppBarLayout\n            android:id=\"@+id\/appBarLayout\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"wrap_content\"&gt;\n\n            &lt;com.google.android.material.appbar.MaterialToolbar\n                android:id=\"@+id\/topAppBar\"\n                style=\"@style\/Widget.MaterialComponents.Toolbar.Primary\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"?attr\/actionBarSize\"\n                app:layout_scrollFlags=\"scroll|enterAlways|snap\"\n                app:menu=\"@menu\/top_app_bar\"\n                app:navigationIcon=\"@drawable\/ic_menu_24dp\"\n                app:title=\"\u6a19\u984c\" \/&gt;\n\n        &lt;\/com.google.android.material.appbar.AppBarLayout&gt;\n\n        &lt;androidx.core.widget.NestedScrollView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            app:layout_behavior=\"@string\/appbar_scrolling_view_behavior\"&gt;\n\n            &lt;androidx.appcompat.widget.LinearLayoutCompat\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:orientation=\"vertical\"&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n            &lt;\/androidx.appcompat.widget.LinearLayoutCompat&gt;\n        &lt;\/androidx.core.widget.NestedScrollView&gt;\n    &lt;\/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;\n&lt;\/layout&gt;\n<\/code><\/pre>\n<h5>MainActivity.kt<\/h5>\n<pre><code class=\"language-kotlin line-numbers\">class MainActivity : AppCompatActivity() {\n\n    private lateinit var binding: ActivityMainBinding\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        binding = DataBindingUtil.setContentView(this, R.layout.activity_main)\n\n        binding.topAppBar.setNavigationOnClickListener {\n            Toast.makeText(this, \"setNavigationOnClickListener\", Toast.LENGTH_SHORT).show()\n        }\n\n        binding.topAppBar.setOnMenuItemClickListener { menuItem -&gt;\n            when (menuItem.itemId) {\n                R.id.favorite -&gt; {\n                    Toast.makeText(this, \"favorite\", Toast.LENGTH_SHORT).show()\n                    true\n                }\n                R.id.search -&gt; {\n                    Toast.makeText(this, \"search\", Toast.LENGTH_SHORT).show()\n                    true\n                }\n                R.id.more -&gt; {\n                    Toast.makeText(this, \"more\", Toast.LENGTH_SHORT).show()\n                    true\n                }\n                else -&gt; false\n            }\n        }\n    }\n}\n<\/code><\/pre>\n<p><a id=\"b\"><\/a><\/p>\n<h4>2.Top app bar \u6ed1\u52d5\u4e0a\u62ac\u6a19\u984c\u8207\u61c9\u7528\u6b04\u5e73\u884c<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2022\/12\/ezgif-1-a123262f7c.gif\" width=\"50%\"\/><\/p>\n<h5>activity_main.xml<\/h5>\n<pre data-language=XML><code class=\"language-markup line-numbers\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;layout 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\"&gt;\n\n    &lt;data&gt;\n\n    &lt;\/data&gt;\n\n    &lt;androidx.coordinatorlayout.widget.CoordinatorLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        tools:context=\".MainActivity\"&gt;\n\n        &lt;com.google.android.material.appbar.AppBarLayout\n            android:id=\"@+id\/appBarLayout\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"128dp\"&gt;\n\n            &lt;com.google.android.material.appbar.CollapsingToolbarLayout\n                app:layout_scrollFlags=\"scroll|exitUntilCollapsed|snap\"\n                app:contentScrim=\"?attr\/colorPrimary\"\n                app:statusBarScrim=\"?attr\/colorPrimaryVariant\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                app:collapsedTitleTextAppearance=\"@style\/TextAppearance.App.CollapsingToolbar.Collapsed\"\n                app:expandedTitleMarginBottom=\"28dp\"\n                app:expandedTitleMarginStart=\"72dp\"\n                app:expandedTitleTextAppearance=\"@style\/TextAppearance.App.CollapsingToolbar.Expanded\"&gt;\n\n                &lt;com.google.android.material.appbar.MaterialToolbar\n                    app:layout_collapseMode=\"pin\"\n                    android:id=\"@+id\/topAppBar\"\n                    style=\"@style\/Widget.MaterialComponents.Toolbar.Primary\"\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"?attr\/actionBarSize\"\n                    android:elevation=\"0dp\"\n                    app:menu=\"@menu\/top_app_bar\"\n                    app:navigationIcon=\"@drawable\/ic_menu_24dp\"\n                    app:title=\"\u6a19\u984c\" \/&gt;\n\n            &lt;\/com.google.android.material.appbar.CollapsingToolbarLayout&gt;\n        &lt;\/com.google.android.material.appbar.AppBarLayout&gt;\n\n        &lt;androidx.core.widget.NestedScrollView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            app:layout_behavior=\"@string\/appbar_scrolling_view_behavior\"&gt;\n\n            &lt;androidx.appcompat.widget.LinearLayoutCompat\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:orientation=\"vertical\"&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n            &lt;\/androidx.appcompat.widget.LinearLayoutCompat&gt;\n        &lt;\/androidx.core.widget.NestedScrollView&gt;\n    &lt;\/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;\n&lt;\/layout&gt;\n<\/code><\/pre>\n<p><a id=\"c\"><\/a><\/p>\n<h4>3.Top app bar \u6ed1\u52d5\u4e0a\u62ac\u6a19\u984c\u8207\u61c9\u7528\u6b04\u5e73\u884c + \u5716\u7247<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2022\/12\/ezgif-1-8c881030e1.gif\" width=\"50%\"\/><\/p>\n<h5>activity_main.xml<\/h5>\n<pre data-language=XML><code class=\"language-markup line-numbers\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;layout 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\"&gt;\n\n    &lt;data&gt;\n\n    &lt;\/data&gt;\n\n    &lt;androidx.coordinatorlayout.widget.CoordinatorLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        tools:context=\".MainActivity\"&gt;\n\n        &lt;com.google.android.material.appbar.AppBarLayout\n            android:id=\"@+id\/appBarLayout\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"152dp\"&gt;\n\n            &lt;com.google.android.material.appbar.CollapsingToolbarLayout\n                app:layout_scrollFlags=\"scroll|exitUntilCollapsed|snap\"\n                app:contentScrim=\"?attr\/colorPrimary\"\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                app:collapsedTitleTextAppearance=\"@style\/TextAppearance.App.CollapsingToolbar.Collapsed\"\n                app:expandedTitleMarginBottom=\"28dp\"\n                app:expandedTitleMarginStart=\"72dp\"\n                app:expandedTitleTextAppearance=\"@style\/TextAppearance.App.CollapsingToolbar.Expanded\"&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatImageView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"match_parent\"\n                    android:src=\"@drawable\/media\"\n                    android:scaleType=\"centerCrop\" \/&gt;\n\n                &lt;com.google.android.material.appbar.MaterialToolbar\n                    android:background=\"@android:color\/transparent\"\n                    app:layout_collapseMode=\"pin\"\n                    android:id=\"@+id\/topAppBar\"\n                    style=\"@style\/Widget.MaterialComponents.Toolbar.Primary\"\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"?attr\/actionBarSize\"\n                    android:elevation=\"0dp\"\n                    app:menu=\"@menu\/top_app_bar\"\n                    app:navigationIcon=\"@drawable\/ic_menu_24dp\"\n                    app:title=\"\u6a19\u984c\" \/&gt;\n\n            &lt;\/com.google.android.material.appbar.CollapsingToolbarLayout&gt;\n        &lt;\/com.google.android.material.appbar.AppBarLayout&gt;\n\n        &lt;androidx.core.widget.NestedScrollView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            app:layout_behavior=\"@string\/appbar_scrolling_view_behavior\"&gt;\n\n            &lt;androidx.appcompat.widget.LinearLayoutCompat\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:orientation=\"vertical\"&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n            &lt;\/androidx.appcompat.widget.LinearLayoutCompat&gt;\n        &lt;\/androidx.core.widget.NestedScrollView&gt;\n    &lt;\/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;\n&lt;\/layout&gt;\n<\/code><\/pre>\n<p><a id=\"d\"><\/a><\/p>\n<h4>4.Top app bar \u64cd\u4f5c\u6b04<\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/badgameshow.com\/fly\/wp-content\/uploads\/2022\/12\/ezgif-1-aef3194108.gif\" width=\"50%\"\/><\/p>\n<h4>acitivty_main.xml<\/h4>\n<pre data-language=XML><code class=\"language-markup line-numbers\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\n&lt;layout 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\"&gt;\n\n    &lt;data&gt;\n\n    &lt;\/data&gt;\n\n    &lt;androidx.coordinatorlayout.widget.CoordinatorLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        tools:context=\".MainActivity\"&gt;\n\n        &lt;androidx.core.widget.NestedScrollView\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            app:layout_behavior=\"@string\/appbar_scrolling_view_behavior\"&gt;\n\n            &lt;androidx.appcompat.widget.LinearLayoutCompat\n                android:layout_width=\"match_parent\"\n                android:layout_height=\"match_parent\"\n                android:orientation=\"vertical\"&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:id=\"@+id\/a\"\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF0000\" \/&gt;\n\n                &lt;androidx.appcompat.widget.AppCompatTextView\n                    android:layout_width=\"match_parent\"\n                    android:layout_height=\"200dp\"\n                    android:background=\"#FF00FF\" \/&gt;\n            &lt;\/androidx.appcompat.widget.LinearLayoutCompat&gt;\n        &lt;\/androidx.core.widget.NestedScrollView&gt;\n    &lt;\/androidx.coordinatorlayout.widget.CoordinatorLayout&gt;\n&lt;\/layout&gt;\n<\/code><\/pre>\n<h5>MainActivity.kt<\/h5>\n<pre><code class=\"language-kotlin line-numbers\">class MainActivity : AppCompatActivity() {\n\n    private lateinit var binding: ActivityMainBinding\n    private var actionMode: ActionMode? = null\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        binding = DataBindingUtil.setContentView(this, R.layout.activity_main)\n\n        val callback = object : ActionMode.Callback {\n\n            override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {\n                menuInflater.inflate(R.menu.top_app_bar, menu)\n                return true\n            }\n\n            override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {\n                return false\n            }\n\n            override fun onActionItemClicked(mode: ActionMode?, item: MenuItem?): Boolean {\n                return when (item?.itemId) {\n                    R.id.favorite -&gt; {\n                        Toast.makeText(this@MainActivity, \"favorite\", Toast.LENGTH_SHORT).show()\n                        true\n                    }\n                    R.id.search -&gt; {\n                        Toast.makeText(this@MainActivity, \"search\", Toast.LENGTH_SHORT).show()\n                        true\n                    }\n                    R.id.more -&gt; {\n                        Toast.makeText(this@MainActivity, \"more\", Toast.LENGTH_SHORT).show()\n                        true\n                    }\n                    else -&gt; false\n                }\n            }\n\n            override fun onDestroyActionMode(mode: ActionMode?) {\n                Toast.makeText(this@MainActivity, \"onDestroyActionMode\", Toast.LENGTH_SHORT).show()\n                actionMode = null\n            }\n        }\n\n        binding.a.setOnClickListener {\n            if (actionMode == null) {\n                actionMode = startSupportActionMode(callback)\n                actionMode?.title = \"selected\"\n            }\n        }\n    }\n}\n<\/code><\/pre>\n<p><a id=\"e\"><\/a><\/p>\n<h4>5.Developer Documents Top app bar<\/h4>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/m2.material.io\/components\/app-bars-top\" title=\"Open in Documents Top app bar\" target=\"_blank\" rel=\"noopener\">Open in Documents Top app bar<\/a><\/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>\u3010Material Design\u3011Android Top app bar \u9802\u90e8\u61c9\u7528\u6b04 \u7bc4\u4f8b Android t &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,78,225],"class_list":["post-1671","post","type-post","status-publish","format-standard","hentry","category-material-design","tag-android","tag-material-design","tag-top-app-bar"],"_links":{"self":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1671","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=1671"}],"version-history":[{"count":5,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1671\/revisions"}],"predecessor-version":[{"id":1803,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/posts\/1671\/revisions\/1803"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/media?parent=1671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/categories?post=1671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/fly\/wp-json\/wp\/v2\/tags?post=1671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}