How to change the size of image in splash screen?

↘锁芯ラ 提交于 2020-08-07 04:17:12

问题


I have a problem, I had a splash screen with an image and a background color but the image rendering is tiny, how can I change it?

This is my launch_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<item>
    <bitmap android:gravity="center" android:src="@drawable/splash" />
</item>

If you know a package or a way to solve it on Android and IOS it will be perfect.


回答1:


I suggest you to use the animated splash available in pub.dev. Animated Splash I have used this plugin in my App and customized it according to my needs. In there, you can change the size of the image and it is written in dart so you can understand it easily also. Hope it help.




回答2:


It seems to be possible in Android starting from API 23 by doing something like this:

    <item
        android:gravity="center"
        android:drawable="@drawable/logo_splash"
        android:width="100dp"
        android:height="100dp">

But I don't know how this will play with different resolutions and screens.

If you know a package or a way to solve it on Android and IOS it will be perfect. :)

There is a plugin that seems to do what you are looking for without the needs for you to configure both IOS & Android, please take a look at https://github.com/henriquearthur/flutter_native_splash

EDIT: Assuming from your question you are talking about a native splash screen, not just the initial page of your app.




回答3:


Try something like this :

Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
          child: Container(
              child: Image.asset(
                  'images/YOUR_IMAGE_URL.png',
                  height: MediaQuery.of(context).size.width / 2.5,
                  width: MediaQuery.of(context).size.width / 2.5,
              )
          ))
     );
  }


来源:https://stackoverflow.com/questions/59784620/how-to-change-the-size-of-image-in-splash-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!