简体   繁体   English

如何在 pub package“flutter_native_splash”中调整图像大小?

[英]How can I resize image in pub package "flutter_native_splash"?

I am using flutter_native_splash 1.3.1 package to add splash screen to the app.我正在使用 flutter_native_splash 1.3.1 package 向应用程序添加启动画面。

The image size is getting displayed bigger than the desired size on the splash screen.图像大小在初始屏幕上显示大于所需大小。 What is right approach to decrease the size of the image on the splash screen?减小初始屏幕上图像大小的正确方法是什么?

Unfortunately, I don't think you can do it.不幸的是,我认为你做不到。 So the option is to resize your image to fit your screen.因此,选项是调整图像大小以适合您的屏幕。 You can read about the resolution in this topic https://github.com/jonbhanson/flutter_native_splash/issues/89您可以阅读本主题中的解决方案https://github.com/jonbhanson/flutter_native_splash/issues/89

It is stated in the documentation that the image will be stretched to fit the screen.文档中说明图像将被拉伸以适应屏幕。 I think the best solution is to make your image with an aspect ratio of 9x16 (portrait) so the proportions stay the same.我认为最好的解决方案是使图像的纵横比为 9x16(纵向),这样比例保持不变。

I was having issues with this.我遇到了这个问题。 I tried a lot of different suggestions from stackoverflow, but nothing worked.我从stackoverflow尝试了很多不同的建议,但没有任何效果。 I eventually just added padding within the image around the logo I wanted to display.我最终只是在我想要显示的徽标周围的图像中添加了填充。 So the logo was about 1/3 of the image, centered in the middle and then used center for gravity所以徽标大约是图像的 1/3,居中居中,然后使用中心作为重心

<bitmap android:gravity="center" android:src="@drawable/splash" />

The images are all called splash.png.这些图像都称为 splash.png。

The images sizes were all squares and had the dimensions:图像尺寸均为正方形,尺寸为:

hdpi 192X192, 
xhdpi 288X288, 
xxhdpi 384X384, 
xxxhdpi 1024X1024

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 你可以在 flutter_native_splash 中调整图像的大小吗? - Can you resize an image in a flutter_native_splash? flutter_native_splash package:图像在 Android 上没有按比例缩小 - flutter_native_splash package: image does not scale down on Android 如何在 flutter 中使用 flutter_native_splash package 更改启动画面的时间? - How to change time for splash screen using flutter_native_splash package in flutter? 如何删除或更改flutter_native_splash? - How to remove or change flutter_native_splash? 如何从应用程序中删除flutter_native_splash? - How to remove flutter_native_splash from app? Flutter:运行此代码后删除flutter_native_splash和flutter_launcher_icons的代码是否安全? - Flutter: Is it safe if I remove the code of flutter_native_splash & flutter_launcher_icons after run this code? 用户登录时使用flutter_native_splash时如何跳过启动画面 - How to skip the splash screen when use flutter_native_splash while user is logged In 如何使用 Flutter_native_splash 在初始屏幕底部添加文本 - How to add text at bottom in splash screen using Flutter_native_splash 找不到 package“flutter_native_splash”。 你忘记添加依赖项了吗? - Could not find package "flutter_native_splash". Did you forget to add a dependency? "根据flutter_native_splash的初始化阶段决定路由" - decide the route based on the initialization phase of flutter_native_splash
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM