简体   繁体   中英

Splash screen image small android

I am using flutter to create an android app, the splash screen image is small, please how do i fix it

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>

What may be making the image small, the bottom image disappears and just shows that small icon, I've put the correct image and sizes in minmap-hdpi, mdpi, etc

在此处输入图像描述

预期结果

Well, It would be helpful if you share the splash activity layout (the.xml file).

I believe it would be easier to control de "splash icon" size if you work on two different layer. Have a drawable for the background and another drawable for the "logo" itself.

On you splash activity layout you can use the background image as the background of your viewgroup (LinearLayout, ConstraintLayout...) and center you logo above it. You can use "wrap_content" for width and height of the logo, or set a fixed size in dp. It leads us to two situations:

If you use a fixed size for your logo, the image may look pixelized on bigger devices.

I recommend using "wrap_content" on the logo, but your image will look small on bigger devices (as it is on the screenshot). To avoid this, you should provide different sizes of the logo and put them on the following folders: - drawable - the default image asset folder - drawable-mdpi - drawable-hdpi - drawable-xdpi - drawable-xxdpi - drawable-xxxdpi

Larger devices will use xxxdpi folder Smaller devices will user mdpi

You can generate all these images size at once here: https://appicon.co/#image-sets

If the device can't find the drawable-...dpi that's recommended for its size, It will use the image from the default folder. (You can check more info about this here: https://developer.android.com/training/multiscreen/screendensities )

You splash layout should be something like this:

    <?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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM