{"id":728,"date":"2023-02-26T15:38:19","date_gmt":"2023-02-26T07:38:19","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=728"},"modified":"2023-04-29T17:11:25","modified_gmt":"2023-04-29T09:11:25","slug":"android-startup-page-black-screen-and-optimal-solution","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/26\/android-startup-page-black-screen-and-optimal-solution\/","title":{"rendered":"Android\u542f\u52a8\u9875\u9ed1\u5c4f\u53ca\u6700\u4f18\u89e3\u51b3\u65b9\u6848"},"content":{"rendered":"<h2>\u524d\u8a00<\/h2>\n<p>\u76f8\u4fe1\u505a\u8fc7Android\u7684\u670b\u53cb\u90fd\u77e5\u9053\uff0c\u5f53\u4e00\u4e2aAPP\u542f\u52a8\u65f6\uff0c\u754c\u9762\u4f1a\u9996\u5148\u5c55\u793a\u4e00\u4e2a\u767d\u5c4f\u6216\u8005\u9ed1\u5c4f\uff0c\u7136\u540e\u518d\u8fdb\u5165\u6b22\u8fce\u9875\uff0c\u7a0d\u4f5c\u505c\u7559\u6700\u540e\u8fdb\u5165APP\u4e3b\u9875\u3002\u90a3\u4e48\u8fd9\u4e2a\u9ed1\u5c4f\u6216\u8005\u767d\u5c4f\u5230\u5e95\u662f\u600e\u4e48\u4e00\u56de\u4e8b\u5462\uff1f\u5b83\u7684\u6700\u597d\u7684\u89e3\u51b3\u65b9\u6848\u5e94\u8be5\u662f\u600e\u6837\u7684\u5462\uff1f<\/p>\n<p><!-- more --><\/p>\n<h2>\u5386\u53f2\u539f\u56e0<\/h2>\n<p>\u5f53\u7cfb\u7edf\u542f\u52a8\u4e00\u4e2aAPP\u65f6\uff0czygote\u8fdb\u7a0b\u4f1a\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8fdb\u7a0b\u53bb\u8fd0\u884c\u8fd9\u4e2aAPP\uff0c\u4f46\u662f\u8fdb\u7a0b\u7684\u521b\u5efa\u662f\u9700\u8981\u65f6\u95f4\u7684\uff0c\u5728\u521b\u5efa\u5b8c\u6210\u4e4b\u524d\uff0c\u754c\u9762\u662f\u5448\u73b0\u5047\u6b7b\u72b6\u6001\u7684\uff0c\u8fd9\u5c31\u5f88\u5c34\u5c2c\u4e86\uff0c\u56e0\u4e3a\u7528\u6237\u4f1a\u4ee5\u4e3a\u6ca1\u6709\u70b9\u5230APP\u800c\u518d\u6b21\u70b9\u51fb\uff0c\u8fd9\u6781\u5927\u7684\u964d\u4f4e\u7528\u6237\u4f53\u9a8c\uff0cAndroid\u9700\u8981\u53ca\u65f6\u505a\u51fa\u53cd\u9988\u53bb\u907f\u514d\u8fd9\u6bb5\u8ff7\u4e4b\u5c34\u5c2c\u3002\u4e8e\u662f\u7cfb\u7edf\u6839\u636e\u4f60\u7684manifest\u6587\u4ef6\u8bbe\u7f6e\u7684\u4e3b\u9898\u989c\u8272\u7684\u4e0d\u540c\u6765\u5c55\u793a\u4e00\u4e2a\u767d\u5c4f\u6216\u8005\u9ed1\u5c4f\u3002\u800c\u8fd9\u4e2a\u9ed1\uff08\u767d\uff09\u5c4f\u6b63\u5f0f\u7684\u79f0\u547c\u5e94\u8be5\u662fPreview Window\uff0c\u5373\u9884\u89c8\u7a97\u53e3\u3002<\/p>\n<p>\u7b80\u8a00\u4e4b\uff0cPreview Window\u5176\u5b9e\u662f\u4e3a\u4e86\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u800c\u6709\u610f\u8bbe\u5b9a\u7684\u3002<\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p>Android\u5728\u9009\u62e9\u5c55\u793a\u9ed1\u5c4f\u6216\u8005\u767d\u5c4f\u7684\u65f6\u5019\uff0c\u662f\u6839\u636e\u8bbe\u5b9a\u7684\u4e3b\u9898\u800c\u4e0d\u540c\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u867d\u7136\u8fdb\u7a0b\u4ee3\u7801\u6ca1\u6709\u88ab\u6267\u884c\uff0c\u4f46\u662f\u914d\u7f6e\u6587\u4ef6\u5374\u88ab\u63d0\u524d\u8bfb\u53d6\uff0c\u7528\u6765\u4f5c\u4e3a\u5c55\u793aPreview Window\u754c\u9762\u7684\u4f9d\u636e\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u4eec\u7684\u89e3\u51b3\u65b9\u6848\u7684\u5207\u5165\u53e3\u5c31\u662f\u6574\u4e2aAPP\u7684manifest\u6587\u4ef6\uff0c\u66f4\u786e\u5207\u7684\u8bf4\u5e94\u8be5\u662f\u4e3b\u9898\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<h3>\u65b9\u6848\u4e00\uff1a\u5f00\u5386\u53f2\u5012\u8f66<\/h3>\n<p>\u8fd9\u4e2a\u65b9\u6848\u5c31\u662f\u7981\u6b62\u52a0\u8f7dPreview Window\uff0c\u5177\u4f53\u505a\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>style.xml<\/p>\n<pre><code class=\"language-xml\">&lt;style name=&quot;AppTheme&quot; parent=&quot;@android:style\/Theme.Holo.NoActionBar&quot;&gt;\n   &lt;item name=&quot;android:windowDisablePreview&quot;&gt;true&lt;\/item&gt;\n&lt;\/style&gt;<\/code><\/pre>\n<p>\u5c06AppTheme\u8bbe\u5b9a\u4e3a\u542f\u52a8\u7684Activity\u7684\u4e3b\u9898\uff0c\u5373\u53ef\u7981\u6b62Preview Window\uff0c\u5f53\u7136\uff0c\u4e5f\u6709\u4eba\u901a\u8fc7\u628aPreview Window\u8bbe\u7f6e\u4e3a\u5168\u900f\u660e\uff0c\u4e5f\u8fbe\u6210\u4e86\u7c7b\u4f3c\u7684\u6548\u679c\u3002<\/p>\n<p>\u7ed3\u679c\u5c31\u662f\uff0c\u5f53\u70b9\u51fbAPP\u65f6\uff0c\u754c\u9762\u4f1a\u65e0\u54cd\u5e94\u4e00\u6bb5\u65f6\u95f4\uff0c\u7136\u540e\u8fdb\u5165APP\u3002<\/p>\n<p>\u4e0d\u63a8\u8350\u8fd9\u4e48\u505a\uff0c\u56e0\u4e3aAndroid\u60f3\u65b9\u8bbe\u6cd5\u63d0\u5347\u7684\u7528\u6237\u4f53\u9a8c\u4e00\u4e0b\u5b50\u88ab\u6253\u56de\u89e3\u653e\u524d\u3002<\/p>\n<h3>\u65b9\u6848\u4e8c\uff1a\u81ea\u5b9a\u4e49Preview Window<\/h3>\n<p>\u5177\u4f53\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>style.xml<\/p>\n<pre><code class=\"language-xml\">&lt;style name=&quot;APPTheme&quot; parent=&quot;@android:style\/Theme.Holo.NoActionBar&quot;&gt;\n    &lt;item name=&quot;android:windowBackground&quot;&gt;@drawable\/splash_bg&lt;\/item&gt;\n    &lt;item name=&quot;android:windowNoTitle&quot;&gt;true&lt;\/item&gt;\n&lt;\/style&gt;<\/code><\/pre>\n<p>\u540c\u6837\u5c06\u4e3b\u9898\u8bbe\u7f6e\u5230\u542f\u52a8\u7684Activity\u7684\u4e3b\u9898\u4e2d\uff0cwindowBackground\u5c31\u662f\u5373\u5c06\u5c55\u793a\u7684Preview Window\u3002\u5176\u4e2dsplash_bg\u53ef\u4ee5\u662f\u4e00\u6574\u5f20\u56fe\u7247\u3002\u5176\u5b9e\u4e5f\u53ef\u4ee5\u662f\u4e00\u4e2a\u80fd\u89e3\u6790\u51fa\u56fe\u7247\u8d44\u6e90\u7684XML\u6587\u4ef6\uff0c\u597d\u50cf\u53ea\u6709layer-list\u8fd9\u79cd\u80fd\u505a\u5f97\u5230\uff0c\u56e0\u4e3a\u5b83\u80fd\u591f\u5c06\u591a\u4e2adrawable\u53e0\u52a0\u8d77\u6765\u5c55\u793a\u3002<\/p>\n<p>splash_bg.xml<\/p>\n<pre><code class=\"language-xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\n&lt;layer-list xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\n    android:opacity=&quot;opaque&quot;&gt;\n    &lt;item android:drawable=&quot;@color\/white&quot;\/&gt;\n    &lt;item&gt;\n        &lt;bitmap\n            android:gravity=&quot;center&quot;\n            android:src=&quot;@drawable\/appblog&quot;\/&gt;\n    &lt;\/item&gt;\n&lt;\/layer-list&gt;<\/code><\/pre>\n<p>\u8bbe\u7f6e\u4e4b\u540e\uff0c\u5f53\u70b9\u51fbAPP\uff0c\u4f1a\u7acb\u9a6c\u8fdb\u5165\u914d\u7f6e\u7684\u754c\u9762\uff0c\u7136\u540e\u542f\u52a8\u6b22\u8fce\u9875\u3002\u5c06Preview Window\u8bbe\u7f6e\u4e3axml\u6587\u4ef6\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u51c6\u786e\u7684\u5b9e\u73b0\u52a8\u753b\u3002<\/p>\n<h3>\u65b9\u6848\u4e09\uff1a\u81ea\u5b9a\u4e49Preview Window\u589e\u5f3a\u7248<\/h3>\n<p>Demo: <a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/ladingwu\/Splash\">https:\/\/github.com\/ladingwu\/Splash<\/a><\/p>\n<p>Preview Window\u53ea\u80fd\u662f\u9759\u6001\u56fe\uff0c\u672c\u8eab\u662f\u4e0d\u5c55\u793a\u52a8\u753b\u7684\uff0c\u6211\u4eec\u8fd9\u91cc\u7684\u52a8\u753b\uff0c\u5176\u5b9e\u662f\u5728\u8fdb\u5165\u6b22\u8fce\u9875\u4e4b\u540e\u7684\u5c55\u793a\u7684\u3002\u5f53\u754c\u9762\u4ecePreview Window\u8df3\u8f6c\u5230\u6b22\u8fce\u9875\u7684\u65f6\u5019\uff0c\u6b22\u8fce\u9875\u5fc5\u987b\u9996\u5148\u5c55\u793a\u4e00\u4e2a\u548cPreview Window\u4e00\u6a21\u4e00\u6837\u7684\u754c\u9762\uff0c\u8ba9\u4eba\u770b\u8d77\u6765\u597d\u50cf\u754c\u9762\u8fd8\u6ca1\u5207\u6362\u4e00\u6837\uff0c\u7136\u540e\u518d\u6162\u6162\u5207\u6362\u5230\u6b22\u8fce\u9875\u3002<\/p>\n<p>\u518d\u6765\u770b\u770b\u4e3a\u4ec0\u4e48\u8bbe\u7f6exml\u7684\u65b9\u5f0f\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u51c6\u786e\u7684\u5b9e\u73b0\u52a8\u753b\uff0c\u5c31\u662f\u56e0\u4e3a\u8981\u4fdd\u8bc1Preview Window\u548c\u6b22\u8fce\u9875\u6700\u5f00\u59cb\u5c55\u793a\u7684\u754c\u9762\u4fdd\u6301\u7edd\u5bf9\u4e00\u81f4\uff0c\u53ea\u6709\u901a\u8fc7xml\u7684\u5e03\u5c40\u624d\u662f\u8fbe\u5230\u8fd9\u79cd\u6548\u679c\u3002<\/p>\n<h3>\u6ce8\u610f\u4e8b\u9879<\/h3>\n<p>\u7ed9Preview Window\u8bbe\u7f6e\u7684\u80cc\u666f\u56fe\u5982\u679c\u4e0d\u505a\u5904\u7406\uff0c\u56fe\u7247\u5c31\u4f1a\u4e00\u76f4\u5b58\u5728\u4e8e\u5185\u5b58\u4e2d\uff0c\u6240\u4ee5\uff0c\u5f53\u6211\u4eec\u8fdb\u5165\u5230\u6b22\u8fce\u9875\u65f6\uff0c\u4e0d\u8981\u5fd8\u8bb0\u628a\u80cc\u666f\u56fe\u8bbe\u7f6e\u4e3a\u7a7a\uff1a<\/p>\n<p>SplashActivity.java<\/p>\n<pre><code class=\"language-java\">@Override\nprotected void onCreate(@Nullable Bundle savedInstanceState) {\n    \/\/\u5c06window\u7684\u80cc\u666f\u56fe\u8bbe\u7f6e\u4e3a\u7a7a\n    getWindow().setBackgroundDrawable(null);\n    super.onCreate(savedInstanceState);\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u76f8\u4fe1\u505a\u8fc7Android\u7684\u670b\u53cb\u90fd\u77e5\u9053\uff0c\u5f53\u4e00\u4e2aAPP\u542f\u52a8\u65f6\uff0c\u754c\u9762\u4f1a\u9996\u5148\u5c55\u793a\u4e00\u4e2a\u767d\u5c4f\u6216\u8005\u9ed1\u5c4f\uff0c\u7136\u540e\u518d\u8fdb\u5165\u6b22\u8fce\u9875 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[213],"tags":[],"class_list":["post-728","post","type-post","status-publish","format-standard","hentry","category-android-performance"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=728"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/728\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}