【问题标题】:Splash screen image small android启动画面图片小android
【发布时间】:2020-04-05 23:33:45
【问题描述】:

我正在使用flutter创建一个android应用程序,启动画面图像很小,请问我该如何解决它

drawable/launch_background.xml

<?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="@color/splash_background" />

    <!-- You can insert your own image assets here -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher" />
    </item>
        <item>
        <bitmap
            android:gravity="bottom"
            android:src="@mipmap/bottom_launcher" />
    </item>
</layer-list>

AndroidManifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com...">
    <!-- io.flutter.app.FlutterApplication is an android.app.Application that
         calls FlutterMain.startInitialization(this); in its onCreate method.
         In most cases you can leave this as-is, but you if you want to provide
         additional functionality it is fine to subclass or reimplement
         FlutterApplication and put your custom class here. -->
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="..."
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

可能是什么使图像变小,底部图像消失并只显示那个小图标,我已将正确的图像和尺寸放在 minmap-hdpi、mdpi 等中

【问题讨论】:

    标签: java android flutter


    【解决方案1】:

    好吧,如果您共享启动活动布局(.xml 文件)会很有帮助。

    我相信如果您在两个不同的图层上工作,控制“启动图标”的大小会更容易。有一个可绘制的背景和另一个可绘制的“标志”本身。

    在您启动活动布局时,您可以使用背景图像作为视图组的背景(LinearLayout、ConstraintLayout...)并将您的徽标居中放置在其上方。您可以使用“wrap_content”作为标志的宽度和高度,或者在 dp 中设置固定大小。它导致我们出现两种情况:

    如果您的徽标使用固定尺寸,则图像在较大的设备上可能看起来像素化。

    我建议在徽标上使用“wrap_content”,但您的图像在较大的设备上看起来会很小(就像在屏幕截图上一样)。为避免这种情况,您应该提供不同尺寸的徽标并将它们放在以下文件夹中: - drawable - 默认图像资源文件夹 - 可绘制的 mdpi - 可绘制的 hdpi - 可绘制的 xdpi - 可绘制-xxdpi -drawable-xxxdpi

    较大的设备将使用 xxxdpi 文件夹 较小的设备将使用 mdpi

    您可以在此处一次生成所有这些图像大小: https://appicon.co/#image-sets

    如果设备找不到为其大小推荐的drawable-...dpi,它将使用默认文件夹中的图像。 (您可以在这里查看更多信息:https://developer.android.com/training/multiscreen/screendensities)

    你的splash布局应该是这样的:

        <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:gravity="center"
        android:background="YOUR BACKGROUND DRAWABLE HERE"
        android:layout_height="match_parent">
    
        <ImageView
            android:layout_width="wrap_content"
            android:src="YOUR LOGO DRAWABLE HERE"
            android:layout_height="wrap_content"/>
    
    </LinearLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多