{"id":67,"date":"2020-11-27T09:41:30","date_gmt":"2020-11-27T01:41:30","guid":{"rendered":"http:\/\/wthee.xyz\/?p=67"},"modified":"2021-01-06T15:20:49","modified_gmt":"2021-01-06T07:20:49","slug":"android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb","status":"publish","type":"post","link":"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/","title":{"rendered":"Android BottomSheetDialogFragment \u2014 \u5706\u89d2\u548c\u81ea\u5b9a\u4e49\u52a8\u753b"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_38 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><a class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" style=\"display: none;\"><span style=\"display: flex;align-items: center;width: 35px;height: 30px;justify-content: center;\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#%E6%95%88%E6%9E%9C\" title=\"\u6548\u679c\">\u6548\u679c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#%E5%9C%86%E8%A7%92\" title=\"\u5706\u89d2\">\u5706\u89d2<\/a><ul class='ez-toc-list-level-5'><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#drawable\" title=\"drawable\">drawable<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#style\" title=\"style\">style<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8A%A8%E7%94%BB\" title=\"\u81ea\u5b9a\u4e49\u52a8\u753b\">\u81ea\u5b9a\u4e49\u52a8\u753b<\/a><ul class='ez-toc-list-level-5'><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#anim\" title=\"anim\">anim<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#style-2\" title=\"style\">style<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#%E5%9F%BA%E7%B1%BB\" title=\"\u57fa\u7c7b\">\u57fa\u7c7b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/wthee.xyz\/index.php\/2020\/11\/27\/android-bottomsheetdialogfragment-%e5%9c%86%e8%a7%92%e5%92%8c%e8%87%aa%e5%ae%9a%e4%b9%89%e5%8a%a8%e7%94%bb\/#%E4%BD%BF%E7%94%A8\" title=\"\u4f7f\u7528\">\u4f7f\u7528<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"%E6%95%88%E6%9E%9C\"><\/span>\u6548\u679c<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/wthee.xyz\/wp-content\/uploads\/2020\/11\/20201127_094019.gif?resize=138%2C300&#038;ssl=1\" alt=\"\u5b9e\u73b0\u6548\u679c\" data-recalc-dims=\"1\" \/><\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E5%9C%86%E8%A7%92\"><\/span>\u5706\u89d2<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<h5><span class=\"ez-toc-section\" id=\"drawable\"><\/span>drawable<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li>res\/drawable\/dialog_background.xml<\/li>\n<\/ul>\n<pre><code class=\"\" data-line=\"\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\n&lt;shape xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\n    android:shape=&quot;rectangle&quot;&gt;\n\n    &lt;corners\n        android:topLeftRadius=&quot;6dp&quot;\n        android:topRightRadius=&quot;6dp&quot; \/&gt;\n    &lt;solid android:color=&quot;#FFFFFF&quot; \/&gt;\n\n&lt;\/shape&gt;<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"style\"><\/span>style<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li>res\/values\/style.xml<\/li>\n<\/ul>\n<pre><code class=\"\" data-line=\"\">&lt;resources&gt;\n\n    &lt;!-- Base application theme. --&gt;\n    &lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.MaterialComponents.DayNight.NoActionBar&quot;&gt;\n\n        ...\n\n        &lt;item name=&quot;bottomSheetDialogTheme&quot;&gt;@style\/AppBottomSheetDialogTheme&lt;\/item&gt;\n\n        ...\n    &lt;\/style&gt;\n\n    &lt;!-- \u4e3b\u9898\u8bbe\u7f6e   --&gt;\n    &lt;style name=&quot;AppBottomSheetDialogTheme&quot; parent=&quot;Theme.MaterialComponents.Light.BottomSheetDialog&quot;&gt;\n        &lt;item name=&quot;bottomSheetStyle&quot;&gt;@style\/AppModalStyle&lt;\/item&gt;\n        &lt;item name=&quot;colorAccent&quot;&gt;@color\/colorAccent&lt;\/item&gt;\n        &lt;item name=&quot;colorPrimary&quot;&gt;@color\/colorPrimary&lt;\/item&gt;\n        &lt;item name=&quot;colorPrimaryDark&quot;&gt;@color\/colorPrimaryDark&lt;\/item&gt;\n    &lt;\/style&gt;\n\n    &lt;!--  \u80cc\u666f\u8bbe\u7f6e  --&gt;\n    &lt;style name=&quot;AppModalStyle&quot; parent=&quot;Widget.Design.BottomSheet.Modal&quot;&gt;\n        &lt;item name=&quot;android:background&quot;&gt;@drawable\/dialog_background&lt;\/item&gt;\n    &lt;\/style&gt;\n&lt;\/resources&gt;<\/code><\/pre>\n<ul>\n<li>PS: \u5982\u679c\u5e03\u5c40\u6dfb\u52a0\u4e86android:background \u5c5e\u6027\uff0c\u8bf7\u53bb\u6389\u3002<\/li>\n<\/ul>\n<pre><code class=\"\" data-line=\"\">&lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\n    android:layout_width=&quot;match_parent&quot;\n    android:layout_height=&quot;match_parent&quot;\n    android:background=&quot;@color\/colorBg&quot;&gt;\n    &lt;!-- \u4e0d\u8981\u6dfb\u52a0 android:background--&gt;\n\n    ...\n    ...\n\n&lt;\/androidx.constraintlayout.widget.ConstraintLayout&gt;<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"%E8%87%AA%E5%AE%9A%E4%B9%89%E5%8A%A8%E7%94%BB\"><\/span>\u81ea\u5b9a\u4e49\u52a8\u753b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<h5><span class=\"ez-toc-section\" id=\"anim\"><\/span>anim<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li>res\/anim\/slide_up.xml<\/li>\n<\/ul>\n<pre><code class=\"\" data-line=\"\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\n&lt;set xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\n    android:duration=&quot;@integer\/fragment_anim&quot;&gt;\n\n    &lt;translate\n        android:fromYDelta=&quot;80%p&quot;\n        android:interpolator=&quot;@android:anim\/decelerate_interpolator&quot;\n        android:toYDelta=&quot;0&quot; \/&gt;\n&lt;\/set&gt;<\/code><\/pre>\n<ul>\n<li>res\/anim\/slide_down.xml<\/li>\n<\/ul>\n<pre><code class=\"\" data-line=\"\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\n&lt;set xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\n    android:duration=&quot;@integer\/fragment_anim&quot;&gt;\n\n    &lt;translate\n        android:fromYDelta=&quot;0&quot;\n        android:interpolator=&quot;@android:anim\/accelerate_interpolator&quot;\n        android:toYDelta=&quot;80%p&quot; \/&gt;\n&lt;\/set&gt;<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"style-2\"><\/span>style<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li>res\/values\/style.xml<\/li>\n<\/ul>\n<pre><code class=\"\" data-line=\"\">&lt;!-- \u81ea\u5b9a\u4e49\u5f39\u51fa\/\u5173\u95ed\u52a8\u753b   --&gt;\n&lt;style name=&quot;DialogAnimation&quot;&gt;\n    &lt;item name=&quot;android:windowEnterAnimation&quot;&gt;@anim\/slide_up&lt;\/item&gt;\n    &lt;item name=&quot;android:windowExitAnimation&quot;&gt;@anim\/slide_down&lt;\/item&gt;\n&lt;\/style&gt;<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"%E5%9F%BA%E7%B1%BB\"><\/span>\u57fa\u7c7b<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<pre><code class=\"\" data-line=\"\">open class CommonBasicDialogFragment : BottomSheetDialogFragment() {\n\n    override fun onActivityCreated(savedInstanceState: Bundle?) {\n        super.onActivityCreated(savedInstanceState)\n        \/\/ \u8bbe\u7f6e\u52a8\u753b\n        dialog?.window?.attributes?.windowAnimations = R.style.DialogAnimation\n    }\n}<\/code><\/pre>\n<h5><span class=\"ez-toc-section\" id=\"%E4%BD%BF%E7%94%A8\"><\/span>\u4f7f\u7528<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li>\u7ee7\u627f\u57fa\u7c7b CommonBasicDialogFragment \u5373\u53ef<\/li>\n<\/ul>\n<pre><code class=\"\" data-line=\"\">class MyFragment() :CommonBasicDialogFragment(){\n    ...\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a BottomSheetDialogFragment  \u6dfb\u52a0\u5706\u89d2\u3001\u81ea\u5b9a\u4e49\u52a8\u753b<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_kad_post_transparent":"default","_kad_post_title":"default","_kad_post_layout":"default","_kad_post_sidebar_id":"","_kad_post_content_style":"default","_kad_post_vertical_padding":"default","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_jetpack_newsletter_access":""},"categories":[3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pcwHG0-15","jetpack-related-posts":[{"id":89,"url":"https:\/\/wthee.xyz\/index.php\/2020\/12\/22\/android-navigation-%e6%b7%bb%e5%8a%a0%e8%bf%87%e6%b8%a1%e6%95%88%e6%9e%9c\/","url_meta":{"origin":67,"position":0},"title":"Android Navigation \u6dfb\u52a0\u8fc7\u6e21\u6548\u679c","author":"wthee","date":"2020\u5e7412\u670822\u65e5","format":false,"excerpt":"\u4f7f\u7528 Container transform\u4e3a\u5bfc\u822a\u7ec4\u4ef6 Navigation \u6dfb\u52a0\u8fc7\u6e21\u52a8\u753b","rel":"","context":"\u5728\u201cAndroid \u5f00\u53d1\u201d\u4e2d","block_context":{"text":"Android \u5f00\u53d1","link":"https:\/\/wthee.xyz\/index.php\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":84,"url":"https:\/\/wthee.xyz\/index.php\/2020\/12\/15\/android-recyclerview-%e5%88%86%e7%bb%84%e6%98%be%e7%a4%ba\/","url_meta":{"origin":67,"position":1},"title":"Android RecyclerView \u5206\u7ec4\u663e\u793a","author":"wthee","date":"2020\u5e7412\u670815\u65e5","format":false,"excerpt":"RecyclerView \u5206\u7ec4\u6548\u679c\u7684\u5b9e\u73b0\u65b9\u5f0f","rel":"","context":"\u5728\u201cAndroid \u5f00\u53d1\u201d\u4e2d","block_context":{"text":"Android \u5f00\u53d1","link":"https:\/\/wthee.xyz\/index.php\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1406,"url":"https:\/\/wthee.xyz\/index.php\/2021\/02\/19\/android-retrofit-%e8%bf%9b%e8%a1%8c-https-%e8%af%b7%e6%b1%82\/","url_meta":{"origin":67,"position":2},"title":"Android Retrofit \u8fdb\u884c https \u8bf7\u6c42","author":"wthee","date":"2021\u5e742\u670819\u65e5","format":false,"excerpt":"Retrofit 2 \u4f7f\u7528\u8bc1\u4e66\u8fdb\u884c https \u8bf7\u6c42\u7684\u4ee3\u7801\u5b9e\u73b0","rel":"","context":"\u5728\u201cAndroid \u5f00\u53d1\u201d\u4e2d","block_context":{"text":"Android \u5f00\u53d1","link":"https:\/\/wthee.xyz\/index.php\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1571,"url":"https:\/\/wthee.xyz\/index.php\/2021\/06\/08\/jetpack-compose-%e4%bd%bf%e7%94%a8-coil-%e5%8a%a0%e8%bd%bd%e5%9b%be%e7%89%87\/","url_meta":{"origin":67,"position":3},"title":"Jetpack Compose \u4f7f\u7528 Coil \u52a0\u8f7d\u56fe\u7247","author":"wthee","date":"2021\u5e746\u67088\u65e5","format":false,"excerpt":"Accompanist \u63d0\u4f9b\u4e86\u6613\u4e8e\u4f7f\u7528\u7684 Painter\uff0c\u5b83\u53ef\u4ee5\u4f7f\u7528 Coil \u56fe\u50cf\u52a0\u8f7d\u5e93\u4ece\u5916\u90e8\u6765\u6e90\u2026","rel":"","context":"\u5728\u201cAndroid \u5f00\u53d1\u201d\u4e2d","block_context":{"text":"Android \u5f00\u53d1","link":"https:\/\/wthee.xyz\/index.php\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1563,"url":"https:\/\/wthee.xyz\/index.php\/2021\/06\/08\/jetpack-compose-chipgroup\/","url_meta":{"origin":67,"position":4},"title":"Jetpack Compose ChipGroup","author":"wthee","date":"2021\u5e746\u67088\u65e5","format":false,"excerpt":"\u5b9e\u73b0 ChipGroup \u7ec4\u4ef6","rel":"","context":"\u5728\u201cAndroid \u5f00\u53d1\u201d\u4e2d","block_context":{"text":"Android \u5f00\u53d1","link":"https:\/\/wthee.xyz\/index.php\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1579,"url":"https:\/\/wthee.xyz\/index.php\/2021\/06\/09\/jetpack-compose-navigation-%e7%9a%84%e4%bd%bf%e7%94%a8\/","url_meta":{"origin":67,"position":5},"title":"Jetpack Compose Navigation \u7684\u4f7f\u7528","author":"wthee","date":"2021\u5e746\u67089\u65e5","format":false,"excerpt":"Compose \u7248\u672c\uff1a1.0.0-beta08 Navigation \u7248\u672c\uff1a2.4.0-alpha0\u2026","rel":"","context":"\u5728\u201cAndroid \u5f00\u53d1\u201d\u4e2d","block_context":{"text":"Android \u5f00\u53d1","link":"https:\/\/wthee.xyz\/index.php\/category\/android\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/posts\/67"}],"collection":[{"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":7,"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":1596,"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/posts\/67\/revisions\/1596"}],"wp:attachment":[{"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wthee.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}