gpt4 book ai didi

java - android 启动画面图像小

转载 作者:行者123 更新时间:2023-12-01 17:35:23 25 4
gpt4 key购买 nike

我正在使用 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 等

enter image description here

expected outcome

最佳答案

嗯,如果您共享启动 Activity 布局(.xml 文件),将会很有帮助。

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

在您的启动 Activity 布局上,您可以使用背景图像作为 View 组(LinearLayout、ConstraintLayout...)的背景,并将 Logo 置于其上方。您可以使用“wrap_content”作为 Logo 的宽度和高度,或设置固定大小(以 dp 为单位)。这导致我们遇到两种情况:

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

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

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

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

如果设备找不到建议的尺寸的可绘制-...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>

关于java - android 启动画面图像小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61050868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com