{"id":1296,"date":"2023-03-18T10:26:57","date_gmt":"2023-03-18T02:26:57","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1296"},"modified":"2023-04-29T09:18:11","modified_gmt":"2023-04-29T01:18:11","slug":"android-splash-adaptation-solves-problem-of-background-image-stretching-during-startup","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/android-splash-adaptation-solves-problem-of-background-image-stretching-during-startup\/","title":{"rendered":"Android Splash\u9002\u914d\u89e3\u51b3\u542f\u52a8\u80cc\u666f\u56fe\u62c9\u4f38\u95ee\u9898"},"content":{"rendered":"<p>\u505a\u8fc7Splash\u7684\u90fd\u77e5\u9053\uff0c\u4e00\u822c\u7684\u505a\u6cd5\u662f\u5728style\u4e2d\u8bbe\u7f6e<code>windowBackground<\/code>\u4e3a\u542f\u52a8\u56fe\uff0c\u6765\u907f\u514d\u51b7\u542f\u52a8\u65f6\u7684\u9ed1\u5c4f\uff0c\u4f46\u662f\u5982\u679c\u653e\u4e00\u5f20\u56fa\u5b9a\u5c3a\u5bf8\u7684\u56fe\u5728\u67d0\u4e9b\u5c4f\u5e55\u4e0a\u5c31\u4f1a\u51fa\u73b0\u62c9\u4f38\uff0c\u5e76\u4e14<code>windowBackground<\/code>\u8fd8\u4e0d\u80fd<code>centerCrop<\/code>\uff0c\u5c31\u7b97\u901a\u8fc7\u8d44\u6e90\u9650\u5b9a\u7b26\u4e5f\u4e0d\u80fd\u5b8c\u7f8e\u7684\u9002\u914d\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developer.android.google.cn\/guide\/topics\/resources\/drawable-resource?hl=zh-cn#LayerList\" title=\"layer-list\">layer-list<\/a><\/p>\n<p><!-- more --><\/p>\n<p>style.xml<\/p>\n<pre><code class=\"language-xml\">&lt;style name=&quot;AppTheme.Splash&quot; parent=&quot;AppTheme&quot;&gt;\n    &lt;item name=&quot;android:windowBackground&quot;&gt;@drawable\/splash&lt;\/item&gt;\n    &lt;item name=&quot;android:windowNoTitle&quot;&gt;true&lt;\/item&gt;\n&lt;\/style&gt;<\/code><\/pre>\n<p>splash.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;&gt;\n    &lt;!--\u767d\u8272\u77e9\u5f62 \u4f5c\u4e3a\u80cc\u666f\u8272--&gt;\n    &lt;item&gt;\n        &lt;shape android:shape=&quot;rectangle&quot;&gt;\n            &lt;solid android:color=&quot;@android:color\/white&quot; \/&gt;\n        &lt;\/shape&gt;\n    &lt;\/item&gt;\n\n    &lt;!--\u5355\u72ec\u7684slogan\u56fe\u7247 \u5e76\u4e14\u8bbe\u7f6e\u4e0b\u95f4\u8ddd--&gt;\n    &lt;item&gt;\n        &lt;!--\u4f4d\u7f6e\u8bbe\u7f6e\u6210\u9760\u4e0b--&gt;\n        &lt;bitmap\n            android:gravity=&quot;center&quot;\n            android:src=&quot;@drawable\/splash_bg&quot; \/&gt;\n    &lt;\/item&gt;\n&lt;\/layer-list&gt;<\/code><\/pre>\n<p>\u9002\u914d\u542f\u52a8\u56fe\u7684\u6838\u5fc3\u4ee3\u7801\u5c31\u662f<code>layer-list<\/code>\uff0c\u5c06\u5143\u7d20\u53e0\u6210\u542f\u52a8\u56fe\u7684\u6837\u5f0f\uff0c\u66f4\u590d\u6742\u4e00\u70b9\u7684\u542f\u52a8\u56fe\u4e5f\u662f\u53ef\u4ee5\u9002\u914d\u7684\u3002<\/p>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/github.com\/android-cn\/android-discuss\/issues\/715\">https:\/\/github.com\/android-cn\/android-discuss\/issues\/715<\/a><br \/>\n\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/blog.csdn.net\/aa464971\/article\/details\/86692198\">https:\/\/blog.csdn.net\/aa464971\/article\/details\/86692198<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u505a\u8fc7Splash\u7684\u90fd\u77e5\u9053\uff0c\u4e00\u822c\u7684\u505a\u6cd5\u662f\u5728style\u4e2d\u8bbe\u7f6ewindowBackground\u4e3a\u542f\u52a8\u56fe\uff0c\u6765\u907f\u514d\u51b7\u542f\u52a8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[325],"tags":[326],"class_list":["post-1296","post","type-post","status-publish","format-standard","hentry","category-android-adaptation","tag-splash"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1296","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=1296"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1296\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}