问题
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