You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android中设置启动页图片为原尺寸50%的实现方案(Flutter开发者无原生Android经验)

Scale Launch Screen Image to 50% of Original Size in Android Layer List

Hey there! Since you're a Flutter dev without native Android experience, let's make this straightforward for you. Here's how to adjust your layer-list XML to scale your launch image down to half its original size:

Modified XML Code

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="?android:colorBackground" />
    <item
        android:width="60dp"
        android:height="60dp"
        android:gravity="center">
        <bitmap
            android:src="@mipmap/launch_image"
            android:scaleType="fitCenter" />
    </item>
</layer-list>

Key Changes Explained

  • Set fixed dimensions on the item: We added android:width="60dp" and android:height="60dp" to the item containing your bitmap. This defines the exact size you want the image to display (half of your original 120x120px). Using dp (density-independent pixels) ensures this scales correctly across different Android screen densities, so you don't have to adjust values for each mipmap folder.
  • Adjust bitmap scaling: The android:scaleType="fitCenter" attribute makes sure your image maintains its original aspect ratio while scaling down to fit within the 60x60dp bounds.
  • Keep centering: android:gravity="center" on the item ensures this resized image stays centered on the splash screen, just like your original setup.

If your original image has different dimensions (not 120x120), just halve the original pixel values and use that number with dp for the width and height attributes.

内容的提问来源于stack exchange,提问作者user4258194

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 18:42:44