{"id":1782,"date":"2022-11-25T17:47:21","date_gmt":"2022-11-25T09:47:21","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/jssdk\/1782.html"},"modified":"2022-11-25T17:47:21","modified_gmt":"2022-11-25T09:47:21","slug":"vivo%e5%b0%8f%e7%aa%97%e9%80%82%e9%85%8d%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/jssdk\/1782.html","title":{"rendered":"vivo\u5c0f\u7a97\u9002\u914d\u6307\u5357"},"content":{"rendered":"<h2>1\u3001\u5c0f\u7a97\u529f\u80fd\u4ecb\u7ecd<\/h2>\n<p><span class=\"wpcom_tag_link\">vivo\u5168\u5c40<\/span>\u5c0f\u7a97\u5728\u5b89\u5353\u539f\u751f\u7684\u591a\u7a97\u53e3\u529f\u80fd\u57fa\u7840\u4e0a\uff0c\u8fdb\u884c\u4e86\u4e00\u7cfb\u5217\u7684\u4f18\u5316\u548c\u521b\u65b0\u3002\u4ee5\u5c0f\u7a97\u7684\u5f62\u5f0f\u5c55\u73b0\u5e94\u7528\uff0c\u5e76\u652f\u6301\u4e0d\u540c\u7a97\u53e3\u5f62\u5f0f\uff08\u5c0f\u7a97\u3001\u5206\u5c4f\u3001\u5168\u5c4f\uff09\u4e4b\u95f4\u5feb\u901f\u5207\u6362\u3002<br \/>\u5c0f\u7a97\u5165\u53e3\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a\u8fd1\u671f\u4efb\u52a1\u5361\u7247\u201c\u5c0f\u7a97\u201d\u9009\u9879\uff0c\u5e94\u7528\u5185\u6ed1\u3001\u60ac\u6d6e\u901a\u77e5\u4e0b\u62c9\u7b49\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 \u8bbe\u7f6e-\u5feb\u6377\u4e0e\u8f85\u52a9-\u591a\u4efb\u52a1 \u8def\u5f84\u8fdb\u5165\u591a\u7a97\u53e3\u529f\u80fd\u8bbe\u7f6e\u9875\uff0c\u4e86\u89e3\u76f8\u5173\u529f\u80fd\u4ecb\u7ecd\u3002<br \/>\uff08\u6ce8\uff1a\u4e0d\u540c\u673a\u578b\u3001\u4e0d\u540c\u7248\u672c\u8868\u73b0\u53ef\u80fd\u6709\u6240\u5dee\u5f02\uff09\u3002<\/p>\n<h2>2\u3001\u5c0f\u7a97\u5e94\u7528\u9002\u914d\u5173\u952e\u70b9<\/h2>\n<p>\u5e94\u7528\u9002\u914d\u5168\u5c40\u5c0f\u7a97\u65f6\uff0c\u56e0\u4e00\u4e9b\u5bb9\u6613\u88ab\u5ffd\u7565\u7684\u9002\u914d\u70b9\uff0c\u5bfc\u81f4\u5e94\u7528\u8fdb\u5165\u5c0f\u7a97\u6a21\u5f0f\u540e\u51fa\u73b0\u517c\u5bb9\u6027\u95ee\u9898\u3002\u4e3a\u6b64\uff0c\u6211\u4eec\u6574\u7406\u4e86\u5168\u5c40\u5c0f\u7a97\u5e94\u7528\u9002\u914d\u7684\u4e94\u5927\u5173\u952e\u70b9\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u9002\u914d\u3002<\/p>\n<p><strong>2.1 \u58f0\u660e\u652f\u6301\u591a\u7a97\u53e3\u6a21\u5f0f<\/strong><br \/>\u5e94\u7528\u9002\u914d\u5168\u5c40\u5c0f\u7a97\u9700\u8981\u5148\u58f0\u660e\u652f\u6301\u5b89\u5353\u539f\u751f\u591a\u7a97\u53e3\uff0c\u548c\u591a\u7a97\u53e3\u9002\u914d\u7b56\u7565\u76f8\u540c\uff0c\u90fd\u9700\u5728 [activity] \u6216 [<span class=\"wpcom_keyword_link\">app<\/span>lication] \u8282\u70b9\u4e2d\u6dfb\u52a0 android:resizeableActivity \u5c5e\u6027\u3002<\/p>\n<p>\u53c2\u8003\u4ee3\u7801\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>&lt;application\n    android:name=\".MyActivity\"\n    android:resizeableActivity=\"true\" \/&gt;\n<\/code><\/pre>\n<p>\u5b89\u5353\u5b98\u65b9\u591a\u7a97\u53e3\u9002\u914d\u53c2\u8003\u94fe\u63a5\uff1ahttps:\/\/developer.android.com\/guide\/topics\/ui\/multi-window.html<\/p>\n<p><strong>2.2 \u6b63\u786e\u5904\u7406Configuration\u53d8\u5316<\/strong><br \/>\u5728\u5e94\u7528\u6a2a\u7ad6\u5c4f\u65cb\u8f6c\u548c\u7a97\u53e3\u5927\u5c0f\u53d8\u5316\u65f6\uff0c\u5982\u9700\u81ea\u884c\u5904\u7406\u591a\u7a97\u53e3\u914d\u7f6e\uff0c\u8bf7\u8bbe\u7f6eandroid:configChanges\u5c5e\u6027\uff0c\u4e4b\u540eActivity\u548c Fragment\u5c06\u6536\u5230 onConfigurationChanged()\u65b9\u6cd5\u56de\u8c03\uff0c\u800c\u4e0d\u662f\u5148\u9500\u6bc1\u518d\u91cd\u5efa\u3002<br \/>\u5728\u7ba1\u7406\u89c6\u56fe\u66f4\u65b0\u3001\u91cd\u65b0\u52a0\u8f7d\u8d44\u6e90\u7b49\u5de5\u4f5c\u65f6\uff0c\u6ce8\u610f\u4e0d\u8981\u6cbf\u7528\u4e4b\u524d\u7684Config\u4fe1\u606f\uff0c\u800c\u9700\u91cd\u65b0\u83b7\u53d6\u6700\u65b0\u7684\u8d44\u6e90\u4fe1\u606f\u3002\u53c2\u8003\u4ee3\u7801\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>&lt;activity\n  android:name=\".MyActivity\"\n  android:configChanges=\"screenSize | smallestScreenSize \n\t\t| screenLayout | orientation\" \/&gt;\n<\/code><\/pre>\n<p><strong>2.3 \u6b63\u786e\u542f\u52a8Activity\u7684task<\/strong><br \/>\u5e94\u7528\u9700\u7ed9Activity\u8bbe\u7f6e\u72ec\u7acb\u7684android:taskAffinity\u5c5e\u6027\uff0c\u4ee5\u9632\u56e0\u7ee7\u627frootActivity\u7684\u591a\u7a97\u53e3\u5c5e\u6027\u5bfc\u81f4\u65e0\u6cd5\u542f\u52a8\u5230\u5c0f\u7a97\u6a21\u5f0f\u3002<br \/>\u56e0\u4e3atask\u4e2d\u7684Activity\u4f1a\u7ee7\u627frootActivity\u7684\u591a\u7a97\u53e3\u5c5e\u6027\u3002\u5982\u679c\u542f\u52a8\u8be5task\u7684rootActivity\u662funresizable\u7684\uff0c\u5219\u5373\u4f7f\u8981\u542f\u52a8\u7684Activity\u662fresizable\u7684\u4e5f\u65e0\u6cd5\u542f\u52a8\u5230\u5c0f\u7a97\u6a21\u5f0f\u3002<br \/>\u53c2\u8003\u4ee3\u7801\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>&lt;activity\n  android:nam<a href=\"https:\/\/app.applebyme.cn\/shengcheng-95.html\">\u6e90\u4ee3\u7801\u751f\u6210app<\/a>e=\".MyActivity\"\n  android:taskAffinity=\"com.test.example\" \/&gt;\n<\/code><\/pre>\n<p><strong>2.4 \u6b63\u786e\u4f7f\u7528Context<\/strong><br \/>\u5e94\u7528\u5728\u9002\u914d\u5c0f\u7a97\u6a21\u5f0f\u65f6\uff0c\u5e94\u4f7f\u7528Activity\u7684Context\u52a0\u8f7d\u5408\u9002\u7684\u8d44\u6e90\u548c\u8ba1\u7b97\u76f8\u5bf9\u4f4d\u7f6e\u3002<br \/>\u5728\u5e94\u7528\u8fdb\u7a0b\u4e2d\uff0c\u5b58\u5728Appl<a href=\"https:\/\/app.applebyme.cn\/shengcheng-43.html\">\u7f51\u7ad9\u8f6capp<\/a>ication\u548cActivity\u4e24\u7c7bContext\uff0c\u5176\u4e2dApplication Context\u5bf9\u5e94\u7684\u662f\u5c4f\u5e55\u8d44\u6e90\u4fe1\u606f\uff0c\u800cActivity Context\u5bf9\u5e94\u7684\u662f\u7a97\u53e3\u7684\u8d44\u6e90\u4fe1\u606f\u3002<br \/>\u5982\u679c\u5e94\u7528\u5728\u5c0f\u7a97\u6a21\u5f0f\u4e0b\u4f7f\u7528\u7684\u662f Application Context\u5904\u7406UI \u76f8\u5173\u7684\u64cd\u4f5c\uff0c\u4f1a\u5bfc\u81f4\u52a0\u8f7d\u7684\u8d44\u6e90\u56e0\u65e0\u6cd5\u611f\u77e5\u5230\u5c0f\u7a97\u800c\u663e\u793a\u5f02\u5e38\u3002<br \/>Activity\u5982\u4f55\u83b7\u53d6\u7279\u5b9a\u7a97\u53e3\u7c7b\u578b\u4e0b\u7684\u7a97\u53e3\u5c3a\u5bf8\uff0c\u53c2\u8003\u4ee3\u7801\uff1a<br \/>java\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>int screenWidthDp = getResources().getConfiguration().screenWidthDp;\nint screenHeightDp = getResources().getConfiguration().screenHeightDp;\n<\/code><\/pre>\n<p>kotlin\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>val screenWidthDp: Int = resources.configuration.screenWidthDp\nval screenHeightDp: Int = resources.configuration.screenHeightDp\n<\/code><\/pre>\n<p><strong>2.5 \u6b63\u786e\u5904\u7406\u5c0f\u7a97\u4e0b\u7684\u6c89\u6d78\u5f0f<\/strong><br \/>\u5c0f\u7a97\u6a21\u5f0f\u4e0b\uff0c\u5e94\u7528\u9876\u90e8\u6709\u4e2a\u529f\u80fdbar\uff0c\u5e94\u7528\u5728\u6c89\u6d78\u5f0f\u9002\u914d\u65f6\u9700\u4e3a\u6b64\u529f\u80fdbar\u9884\u7559\u4e00\u5b9a\u7a7a\u95f4\u3002\u56e0\u6b64\u5e94\u7528\u5728\u5e03\u5c40\u65f6\uff0c\u9700\u8981\u76d1\u542c\u5b89\u5353\u539f\u751f\u7684WindowInsetsListener\u63a5\u53e3\u56de\u8c03\uff0c\u9488\u5bf9captionBarInsets\u53d8\u5316\u6765\u5904\u7406view\u9ad8\u5ea6\uff0c\u6ce8\u610f\u4e0d\u8981\u4f7f\u7528\u56fa\u5b9a\u9ad8\u5ea6\uff01\uff01\uff01<br \/><img decoding=\"async\" src=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221121163406771.jpg\" alt=\"2.5.jpg\"><img decoding=\"async\" class=\"j-lazy\" src=\"https:\/\/www.yimenapp.com\/kb-yimen\/wp-content\/themes\/justnews\/themer\/assets\/images\/lazy.png\" data-original=\"https:\/\/kb.cdn.yimenapp.com\/yimen\/2022\/11\/20221121163406771.jpg\" alt=\"2.5.jpg\"><\/p>\n<p>\u53c2\u8003\u4ee3\u7801\uff1a<br \/>java\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>getWindow().getDecorView().setOnApplyWindowInsetsListener((v, insets) -&gt; {\n    \/\/\u5e94\u7528\u5728\u56de\u8c03\u4e2d\u8ba1\u7b97view\u9ad8\u5ea6\n    return insets;\n});\n<\/code><\/pre>\n<p>kotlin\uff1a<\/p>\n<pre class=\"wp-block-code\"><code>window.decorView.setOnApplyWindowInsetsListener { v: View?, insets: WindowInsets -&gt;\n    \/\/\u5e94\u7528\u5728\u56de\u8c03\u4e2d\u8ba1\u7b97view\u9ad8\u5ea6\n    insets\n}\n<\/code><\/pre>\n<p><strong>2.6 \u5176\u4ed6\u754c\u9762\u5e03\u5c40\u5efa\u8bae<\/strong><br \/>\u2022\u3000\u5e03\u5c40\u53c2\u6570\u5c3d\u91cf\u4f7f\u7528\u76f8\u5bf9\u7684\u5e03\u5c40\u53c2\u6570\uff0c\u4e0d\u8981\u4f7f\u7528\u56fa\u5b9a\u5c3a\u5bf8<br \/>\u2022\u3000\u907f\u514d\u6839\u636e\u5c4f\u5e55\u5927\u5c0f\uff0c\u8f93\u5165\u6cd5\u9ad8\u5ea6\u7b49\u8ba1\u7b97view\u7684\u5e03\u5c40\u53c2\u6570\uff0c\u5982\u8bbe\u7f6epopwindow\u3001dialog\u7b49\u5b50\u7a97\u53e3\u7684\u4f4d\u7f6e\u65f6\uff0c\u907f\u514d\u4f7f\u7528\u6574\u4e2a\u5c4f\u5e55\u7684\u76f8\u5bf9\u4f4d\u7f6e<br \/>\u2022\u3000\u907f\u514d\u5bf9DecorView\uff0ccontent\u7b49\u6839\u5e03\u5c40\u8fdb\u884c\u5b9a\u5236\uff0c\u6bd4\u5982\u8bbe\u7f6eDecorView\u7684\u80cc\u666f\u3001\u5728DecorView\u6dfb\u52a0\u5b50\u5e03\u5c40\u7b49<br \/>\u2022\u3000\u6ce8\u610f\u751f\u547d\u5468\u671f\u5904\u7406\uff0c\u5982\u5c0f\u7a97\u6a21\u5f0f\u4e0b\u51fa\u73b0\u9875\u9762\u70b9\u51fb\u3001\u62d6\u52a8\u65e0\u54cd\u5e94\u95ee\u9898\uff0c\u53ef\u80fd\u8ddf\u5e03\u5c40\u6216\u751f\u547d\u5468\u671f\u6709\u5173<br \/>\u2022\u3000\u907f\u514d\u6839\u636e\u7269\u7406\u5c4f\u5e55\u65b9\u5411\u8bbe\u7f6e\u5f53\u524d\u529f\u80fd\u6216\u5e03\u5c40<\/p>\n<p>\u7f16\u8f91\uff1ayimen\uff0c\u5982\u82e5\u8f6c\u8f7d\uff0c\u8bf7\u6ce8\u660e\u51fa\u5904\uff1ahttps:\/\/www.yimenapp.com\/kb-yimen\/11591\/<\/p>\n<p>\u90e8\u5206\u5185\u5bb9\u6765\u81ea\u7f51\u7edc\u6295\u7a3f\uff0c\u5982\u6709\u4fb5\u6743\u8054\u7cfb\u7acb\u5220<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5c0f\u7a97\u529f\u80fd\u4ecb\u7ecdvivo\u5168\u5c40\u5c0f\u7a97\u5728\u5b89\u5353\u539f\u751f\u7684\u591a\u7a97\u53e3\u529f\u80fd\u57fa\u7840\u4e0a\uff0c\u8fdb\u884c\u4e86\u4e00\u7cfb\u5217\u7684\u4f18\u5316\u548c\u521b\u65b0\u3002\u4ee5\u5c0f\u7a97\u7684\u5f62\u5f0f\u5c55\u73b0\u5e94\u7528\uff0c\u5e76\u652f\u6301\u4e0d\u540c\u7a97\u53e3\u5f62\u5f0f\uff08\u5c0f\u7a97\u3001\u5206\u5c4f\u3001\u5168\u5c4f\uff09\u4e4b\u95f4\u5feb\u901f\u5207\u6362\u3002\u5c0f\u7a97\u5165\u53e3\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\uff1a\u8fd1\u671f\u4efb\u52a1\u5361\u7247\u201c\u5c0f\u7a97\u201d\u9009\u9879\uff0c\u5e94\u7528\u5185\u6ed1\u3001\u60ac\u6d6e\u901a\u77e5\u4e0b\u62c9\u7b49\u3002\u7528\u6237\u53ef\u4ee5\u901a\u8fc7 \u8bbe\u7f6e-\u5feb\u6377\u4e0e\u8f85\u52a9-\u591a\u4efb\u52a1 \u8def\u5f84\u8fdb\u5165\u591a\u7a97\u53e3\u529f\u80fd\u8bbe\u7f6e\u9875<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[1151,1268,861],"class_list":["post-1782","post","type-post","status-publish","format-standard","hentry","category-jssdk","tag-1151","tag-1268","tag-861"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/1782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=1782"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/1782\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=1782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=1782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=1782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}