简体   繁体   English

如何在 flutter 应用程序中管理 android 和 ios 的图像分辨率?

[英]How to manage images resolution in flutter app for both android and ios?

In Native ios and native android, 1x, 2x,3x images and mdpi, xdpi etc images sizes can use.在原生 ios 和原生 android 中,可以使用 1x、2x、3x 图像和 mdpi、xdpi 等图像尺寸。 For flutter app, how to manage this?对于 flutter 应用程序,如何管理这个?

If i use all those sizes, app size will be huge and also hard to manage.如果我使用所有这些尺寸,应用程序的大小将会很大并且也很难管理。 Otherwise if i use 1x size only for different device sizes, it will be shrinked or blurred.否则,如果我仅对不同的设备尺寸使用 1x 尺寸,它将被缩小或模糊。

Can anyone suggest me the solution for this?谁能建议我解决这个问题?

Updated question: For each and every image, which sizes i can ask my UI/UX designer to provide for ios and android?更新的问题:对于每个图像,我可以要求我的 UI/UX 设计师为 ios 和 android 提供哪些尺寸?

If you don't use internet, converting pngs or jpgs to webp because it has less size than others.如果您不使用互联网,请将 png 或 jpg 转换为 webp,因为它的大小比其他文件小。 It may be good solution for you.这对您来说可能是一个很好的解决方案。

Either you have an offline image or loading from the network.您有离线图像或从网络加载。 You just need to manage it on Screen Size.您只需要在屏幕尺寸上管理它。

You can give custom height and width to the image or parent widget to show accordingly screen resolutions.您可以为图像或父小部件提供自定义高度和宽度,以显示相应的屏幕分辨率。

Here is the different way to get width and height.这是获取宽度和高度的不同方法。

Getting width is easy but height can be tricky , following are the ways to deal with height获取width很容易,但height可能很棘手,以下是处理height的方法

// Full screen width and height
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;

// Height (without SafeArea)
var padding = MediaQuery.of(context).padding;
double height1 = height - padding.top - padding.bottom;

// Height (without status bar)
double height2 = height - padding.top;

// Height (without status and toolbar)
double height3 = height - padding.top - kToolbarHeight;

You can use width /2 or /3 for the width of the image and the same for height.您可以使用 width /2/3作为图像的宽度,也可以使用相同的高度。 It will work for Android, iOS, or other platforms too.它也适用于 Android、iOS 或其他平台。

Do let me know if you have any questions.如果您有任何问题,请告诉我。

暂无
暂无

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

相关问题 flutter 变体使用flutter_flavorizr - 如何自定义应用程序图标(android 和 IOS)? - flutter variant flavors using flutter_flavorizr - how to customize app icon (both android and IOS)? 如何在 Android 和 iOS 上使用 Flutter 实现振动? - How to implement vibration with Flutter for both Android and iOS? 如何在颤振中为 ios、android 和 web 添加不同分辨率的图像? - How to add different resolution image in flutter for ios,android and web? 有什么方法可以同时为两者(android,ios)创建一个应用程序图标? - Is there any way to create an app icon in a flutter for both(android, ios)? 适用于 iOS 和安卓的 Flutter 应用程序中的 Facebook 奖励广告集成 - Facebook rewarded ads integration in flutter app for both ios and android PWA 能否嵌入 Flutter 应用程序中,用于 Android 和 iOS? - Can a PWA be embedded in a Flutter app for both Android and iOS? 适用于 android 和 ios(?) - Flutter-developing kiosk app for both android and ios(?) 如何同时在 Android 和 IOS 模拟器中查看我的 flutter 应用程序 output? - How can i see my flutter app output in both Android and IOS simulator simultaneously? 我可以为 android 和 ios 应用程序使用相同的 Flutter 应用程序吗? - Can I use same flutter app for both android and ios apps? 如何在开发过程中同时使用 Android 和 IOS 模拟器来测试我的 Flutter 应用程序? - How to use both Android and IOS simulator simultaneously to test my flutter app during development?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM