英文:
Splash screen image small 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>
英文:
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
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<?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>
<!-- end snippet -->
AndroidManifest
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<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>
<!-- end snippet -->
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
答案1
得分: 1
以下是翻译好的内容:
"在你分享闪屏活动布局(.xml文件)时将会很有帮助。
我认为,如果你在两个不同的层上工作,控制“闪屏图标”的大小会更容易。为背景创建一个可绘制资源,为“标志”本身创建另一个可绘制资源。
在你的闪屏活动布局中,你可以使用背景图像作为你的视图组(LinearLayout,ConstraintLayout等)的背景,并将标志居中放置在其上。你可以对标志的宽度和高度使用“wrap_content”,或者以dp为单位设置固定大小。这会导致两种情况:
如果你为标志使用固定大小,图像在较大的设备上可能会看起来像素化。
我建议在标志上使用“wrap_content”,但在较大的设备上,你的图像会显得很小(就像屏幕截图上一样)。为了避免这种情况,你应该提供不同大小的标志,并将它们放在以下文件夹中:
- drawable - 默认的图像资源文件夹
- drawable-mdpi
- drawable-hdpi
- drawable-xdpi
- drawable-xxdpi
- drawable-xxxdpi
较大的设备将使用xxxdpi文件夹
较小的设备将使用mdpi
你可以一次生成所有这些图像大小,https://appicon.co/#image-sets 这里可以生成。
如果设备找不到适用于其尺寸的drawable-...dpi文件夹,它将使用默认文件夹中的图像。
(你可以在这里查看更多信息:https://developer.android.com/training/multiscreen/screendensities )
你的闪屏布局应该类似于以下内容:
<?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>
<details>
<summary>英文:</summary>
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][1]
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][2] )
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>
[1]: https://appicon.co/#image-sets
[2]: https://developer.android.com/training/multiscreen/screendensities
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论