{"id":6137,"date":"2022-02-26T11:48:56","date_gmt":"2022-02-26T03:48:56","guid":{"rendered":"http:\/\/xinyiworld.top\/wordpress\/?p=6137"},"modified":"2026-02-28T15:06:08","modified_gmt":"2026-02-28T07:06:08","slug":"android%e6%b2%89%e6%b5%b8%e5%bc%8f%e7%8a%b6%e6%80%81%e6%a0%8f","status":"publish","type":"post","link":"http:\/\/xinyiworld.top\/wordpress_it\/?p=6137","title":{"rendered":"\u7cfb\u7edf\u680f"},"content":{"rendered":"<p><a href=\"https:\/\/www.yisu.com\/zixun\/217057.html\">https:\/\/www.yisu.com\/zixun\/217057.html<\/a><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_16 counter-hierarchy counter-decimal ez-toc-grey\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\">\u76ee\u5f55<\/p>\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;\"><i class=\"ez-toc-glyphicon ez-toc-icon-toggle\"><\/i><\/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-1\"><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=6137\/#%E6%B2%89%E6%B5%B8%E5%BC%8F%E7%8A%B6%E6%80%81%E6%A0%8F%E7%9B%B8%E5%85%B3API\" title=\"\u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u76f8\u5173API\">\u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u76f8\u5173API<\/a><ul class=\"ez-toc-list-level-2\"><li class=\"ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=6137\/#%E5%AE%9E%E7%8E%B0%E4%BE%B5%E5%85%A5%E6%9C%892%E7%A7%8D%E6%96%B9%E5%BC%8F%EF%BC%88%E5%85%A8%E5%B1%8F%EF%BC%89\" title=\"\u5b9e\u73b0\u4fb5\u5165\u67092\u79cd\u65b9\u5f0f\uff08\u5168\u5c4f\uff09\">\u5b9e\u73b0\u4fb5\u5165\u67092\u79cd\u65b9\u5f0f\uff08\u5168\u5c4f\uff09<\/a><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-2\"><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=6137\/#%E8%AE%BE%E7%BD%AE%E5%81%8F%E7%A7%BB%E8%B7%9D%E7%A6%BB\" title=\"\u8bbe\u7f6e\u504f\u79fb\u8ddd\u79bb\">\u8bbe\u7f6e\u504f\u79fb\u8ddd\u79bb<\/a><\/li><\/ul><\/li><li class=\"ez-toc-page-1 ez-toc-heading-level-1\"><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/xinyiworld.top\/wordpress_it\/?p=6137\/#%E8%AE%BE%E7%BD%AE%E7%B3%BB%E7%BB%9F%E6%A0%8F%E8%A1%8C%E4%B8%BA\" title=\"\u8bbe\u7f6e\u7cfb\u7edf\u680f\u884c\u4e3a\">\u8bbe\u7f6e\u7cfb\u7edf\u680f\u884c\u4e3a<\/a><\/li><\/ul><\/nav><\/div>\n<h1><span class=\"ez-toc-section\" id=\"%E6%B2%89%E6%B5%B8%E5%BC%8F%E7%8A%B6%E6%80%81%E6%A0%8F%E7%9B%B8%E5%85%B3API\"><\/span>\u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u76f8\u5173API<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u5bf9\u6bd4\u7ef4\u5ea6<\/th>\n<th style=\"text-align: left;\"><strong><code>android:fitsSystemWindows=&quot;true&quot;<\/code><\/strong><\/th>\n<th style=\"text-align: left;\"><strong><code>android:windowTranslucentStatus=&quot;true&quot;<\/code><\/strong><\/th>\n<th style=\"text-align: left;\"><strong><code>window.statusBarColor<\/code><\/strong><\/th>\n<th style=\"text-align: left;\"><strong><code>WindowCompat.setDecorFitsSystemWindows(window, false)<\/code><\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><strong>\u672c\u8d28<\/strong><\/td>\n<td style=\"text-align: left;\">\u5e03\u5c40\u5c5e\u6027<\/td>\n<td style=\"text-align: left;\">\u4e3b\u9898\u5c5e\u6027<\/td>\n<td style=\"text-align: left;\">Window API<\/td>\n<td style=\"text-align: left;\">Window API<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u5f15\u5165\u7248\u672c<\/strong><\/td>\n<td style=\"text-align: left;\">API 1<\/td>\n<td style=\"text-align: left;\">API 19<\/td>\n<td style=\"text-align: left;\">API 21<\/td>\n<td style=\"text-align: left;\">API 30 (\u517c\u5bb9\u5e93)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u6838\u5fc3\u4f5c\u7528<\/strong><\/td>\n<td style=\"text-align: left;\">\u8ba9View<strong>\u81ea\u52a8\u907f\u8ba9<\/strong>\u7cfb\u7edf\u680f<\/td>\n<td style=\"text-align: left;\">\u8ba9\u72b6\u6001\u680f<strong>\u53d8\u534a\u900f\u660e<\/strong><\/td>\n<td style=\"text-align: left;\"><strong>\u8bbe\u7f6e\u72b6\u6001\u680f\u989c\u8272<\/strong><\/td>\n<td style=\"text-align: left;\">\u8ba9\u7a97\u53e3<strong>\u4e0d\u518d\u81ea\u52a8\u907f\u8ba9<\/strong>\u7cfb\u7edf\u680f<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u5bf9Insets\u7684\u5f71\u54cd<\/strong><\/td>\n<td style=\"text-align: left;\"><strong>\u4f7f\u7528<\/strong>\u7cfb\u7edf\u63d0\u4f9b\u7684Insets<\/td>\n<td style=\"text-align: left;\">\u5c06\u72b6\u6001\u680fInsets<strong>\u8bbe\u4e3a0<\/strong><\/td>\n<td style=\"text-align: left;\"><strong>\u4e0d\u5f71\u54cd<\/strong>Insets<\/td>\n<td style=\"text-align: left;\"><strong>\u4fdd\u7559<\/strong>Insets\uff0c\u4ea4\u51fa\u63a7\u5236\u6743<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u662f\u5426\u6539\u53d8\u72b6\u6001\u680f\u5916\u89c2<\/strong><\/td>\n<td style=\"text-align: left;\">\u274c \u4e0d\u5f71\u54cd<\/td>\n<td style=\"text-align: left;\">\u2705 \u53d8\u6210\u534a\u900f\u660e<\/td>\n<td style=\"text-align: left;\">\u2705 \u6539\u53d8\u989c\u8272<\/td>\n<td style=\"text-align: left;\">\u274c \u4e0d\u5f71\u54cd<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u662f\u5426\u80fd\u5b9e\u73b0\u5168\u5c4f<\/strong><\/td>\n<td style=\"text-align: left;\">\u274c \u4e0d\u80fd<\/td>\n<td style=\"text-align: left;\">\u26a0\ufe0f \u90e8\u5206\u80fd\uff08\u5185\u5bb9\u4e0a\u79fb\uff09<\/td>\n<td style=\"text-align: left;\">\u274c \u4e0d\u80fd\u5355\u72ec\u5b9e\u73b0<\/td>\n<td style=\"text-align: left;\">\u2705 \u53ef\u4ee5\uff08\u9700\u914d\u5408\u76d1\u542c\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><strong>\u63a7\u5236\u6743<\/strong><\/td>\n<td style=\"text-align: left;\">\u7cfb\u7edf\u81ea\u52a8<\/td>\n<td style=\"text-align: left;\">\u7cfb\u7edf\u81ea\u52a8<\/td>\n<td style=\"text-align: left;\">\u5f00\u53d1\u8005\u624b\u52a8<\/td>\n<td style=\"text-align: left;\">\u5f00\u53d1\u8005\u624b\u52a8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span class=\"ez-toc-section\" id=\"%E5%AE%9E%E7%8E%B0%E4%BE%B5%E5%85%A5%E6%9C%892%E7%A7%8D%E6%96%B9%E5%BC%8F%EF%BC%88%E5%85%A8%E5%B1%8F%EF%BC%89\"><\/span>\u5b9e\u73b0\u4fb5\u5165\u67092\u79cd\u65b9\u5f0f\uff08\u5168\u5c4f\uff09<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>\n<p>\u7b2c1\u79cd\uff1a\u4e3b\u9898\u5c5e\u6027<code>android:windowTranslucentStatus=&quot;true&quot;<\/code>\uff0c\u72b6\u6001\u680f\u4f1a\u56fa\u5b9a\u534a\u900f\u660e\u989c\u8272\u4e14\u72b6\u6001\u680f\u989c\u8272API\u8c03\u7528\u65e0\u6548 <code>window.statusBarColor <\/code>\uff0cView\u4f1a\u4fb5\u5165\u72b6\u6001\u680f\u3002<\/p>\n<\/li>\n<li>\n<p>\u7b2c2\u79cd\uff1a\u901a\u8fc7<code>WindowCompat.setDecorFitsSystemWindows(window, false)<\/code>\uff0c\u4f46\u662f\u72b6\u6001\u680f\u4e0d\u4f1a\u81ea\u52a8\u534a\u900f\u660e\uff0c\u8c03\u7528API<code>window.statusBarColor <\/code>\u8bbe\u7f6e\u4f1a\u751f\u6548\u3002<\/p>\n<\/li>\n<li>\n<p>\u7b2c3\u79cd\uff1a\u901a\u8fc7<code>enableEdgeToEdge<\/code>API\uff0c\u6b64API\u662f\u5bf9<code>WindowCompat.setDecorFitsSystemWindows(window, false)<\/code>\u53ca\u72b6\u6001\u680f\u8bbe\u7f6e\u4e3a\u900f\u660e\u7b49\u65b9\u6cd5\u7684\u5c01\u88c5\u3002<\/p>\n<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"%E8%AE%BE%E7%BD%AE%E5%81%8F%E7%A7%BB%E8%B7%9D%E7%A6%BB\"><\/span>\u8bbe\u7f6e\u504f\u79fb\u8ddd\u79bb<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>\u7cfb\u7edf\u81ea\u52a8\u8bbe\u7f6e\uff1aandroid:fitsSystemWindows=&quot;true&quot;<\/li>\n<li>\n<p>\u7cbe\u786e\u8bbe\u7f6e<br \/>\n<code>ViewCompat.setOnApplyWindowInsetsListener<\/code> \u662f Android \u4e2d\u5904\u7406<strong>\u7a97\u53e3\u5185\u8fb9\u8ddd\uff08Insets\uff09<\/strong>\u7684\u6838\u5fc3API\uff0c\u5b83\u7684\u4f5c\u7528\u662f<strong>\u8ba9\u4f60\u80fd\u591f\u7cbe\u786e\u63a7\u5236\u6bcf\u4e2a View \u5982\u4f55\u54cd\u5e94\u7cfb\u7edf\u680f\uff08\u72b6\u6001\u680f\u3001\u5bfc\u822a\u680f\u3001\u952e\u76d8\u7b49\uff09\u7684\u7a7a\u95f4\u53d8\u5316<\/strong>\u3002<\/p>\n<pre><code>ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { view, insets -&gt;\n        val systemBarsInsets = insets.getInsets(\n            WindowInsetsCompat.Type.systemBars()\n        )\n\n        \/\/ \u8fd9\u91cc\u4f60\u53ef\u4ee5\u7cbe\u786e\u63a7\u5236\uff1a\n        \/\/ - \u60f3\u8ba9\u80cc\u666f\u56fe\u5168\u5c4f\uff1a\u4e0d\u7ed9 view \u8bbe\u7f6e padding\n        \/\/ - \u60f3\u8ba9\u6587\u5b57\u907f\u5f00\u72b6\u6001\u680f\uff1a\u7ed9 TextView \u8bbe\u7f6e top padding\n\n        \/\/ \u4f8b\u5982\uff1a\u8ba9\u6574\u4e2a\u5e03\u5c40\u5ef6\u4f38\u5230\u72b6\u6001\u680f\u540e\u9762\n        view.setPadding(\n            view.paddingLeft,\n            0,  \/\/ top padding \u8bbe\u4e3a 0\uff0c\u5185\u5bb9\u5c31\u4f1a\u9876\u5230\u9876\u90e8\n            view.paddingRight,\n            view.paddingBottom\n        )\n\n        insets\n    }<\/code><\/pre>\n<\/li>\n<\/ul>\n<h1><span class=\"ez-toc-section\" id=\"%E8%AE%BE%E7%BD%AE%E7%B3%BB%E7%BB%9F%E6%A0%8F%E8%A1%8C%E4%B8%BA\"><\/span>\u8bbe\u7f6e\u7cfb\u7edf\u680f\u884c\u4e3a<span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p><code>windowInsetsController.systemBarsBehavior<\/code><\/p>\n<button class=\"simplefavorite-button\" data-postid=\"6137\" data-siteid=\"1\" data-groupid=\"1\" data-favoritecount=\"0\" style=\"\">\u6536\u85cf <i class=\"sf-icon-star-empty\"><\/i><\/button>","protected":false},"excerpt":{"rendered":"<p>https:\/\/www.yisu.com\/zixun\/217057.html \u76ee\u5f55 \u6c89\u6d78\u5f0f\u72b6\u6001\u680f\u76f8\u5173 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[389],"tags":[],"_links":{"self":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/6137"}],"collection":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6137"}],"version-history":[{"count":12,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/6137\/revisions"}],"predecessor-version":[{"id":16180,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=\/wp\/v2\/posts\/6137\/revisions\/16180"}],"wp:attachment":[{"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6137"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinyiworld.top\/wordpress_it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}