I build my app with expo react native, how can I make my splash screen image cover the screen on app launch, so that the white space above and below did not show:
see Image below
See code below splashscreen.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/splashscreen_background"/>
</layer-list>
I will appreciate if you help edit splashscreen.xml code for the answer thanks.
You can try changing the resizeMode prop to cover in the splash object in app.js file. It is set to contain by default.
Like this:
"splash": {
"image": "./assets/images/splashScreen.png",
"resizeMode": "cover",
"backgroundColor": "#000000"
},
Related
I have seen a lot of articles and youtube videos and tried everything however i cannot change the android splash screen color
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/background" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/launch_image" />
</item>
</layer-list>
values/colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background">#2196F3</color>
</resources>
Production Build with key output:
It is really simple to create Native splash screens using this package.
https://pub.dev/packages/flutter_native_splash
add this package in your dev-dependencies
dev_dependencies:
flutter_native_splash: ^0.2.9
add the following code in your YAML file.
flutter_native_splash:
color: "#42a5f5"
image: "assets/splash.png"
and run the command
flutter pub run flutter_native_splash:create
That's all, This package will take care of all the process.
FYI: This creates native splash screens for both Android and iOS, but
you can control it too. if you want to create only for Android, you
can set the iOS property to false. Documentation of the Package is
pretty clear.
I am using the default splash screen provided by flutter. The app icon shows in the middle of the screen. But it appears very small. If I go to the launch_background.xml , I am not able to change the size properties of the bitmap. How to change the size of the bitmap ?
The launch_background.xml looks like this:
<?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="#android:color/white" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/dev_icon" />
</item>
</layer-list>
I referred to this, but of no use.
Any help is appreciated. I am a complete beginner in flutter.
Inside your main function, use home as SplashScreen(_), the parameters are as follows and change the logo size.
runApp(MaterialApp(
home: CustomSplash(
imagePath: '#drawable/dev_icon',
backGroundColor: Colors.deepOrange,
animationEffect: 'zoom-in',
logoSize: 200,
home: MyApp(),
customFunction: duringSplash,
duration: 2500,
type: CustomSplashType.StaticDuration,
outputAndHome: op,
),
I want to make the splash screen background transparent so that it shows only an icon on the screen when the app starts.
What I have done so far in launch_background.xml for Android:
<?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="#android:color/transparent" />
<item>
<bitmap
android:src="#drawable/index"
android:gravity="center"
/>
</item>
</layer-list>
But what I got was a black background like:
The Image
What I want, something like this:
The image
How to approach this problem properly? Thank you!
BTW: What about IOS?
I downloaded a transparent image, and used it as my background image under flutter_native_splash in flutter. It worked perfectly.
flutter_native_splash:
background_image: "lib/assets/transpbackground.png"
image: lib/assets/translogo.png
android_gravity: center
fullscreen: true
ios_content_mode: center
..android: true
..ios: true
I'm working on the splash screen for my Flutter app, and in drawable folder I have to create a file called colors.xml in order to change background color for my splash screen. I'm finding it hard to make it a gradient color. My intention is to create a gradient background color that would start at the top left and end at bottom right, using two different colors. Does anyone have an example of how to do that in Flutter? Thanks!
P.S. An is there a difference in the process for android and ios?
1 In \android\app\src\main\res\drawable\launch_background.xml
change this :
<item android:drawable="#android:color/white" />
to :
<item android:drawable="#drawable/gradient_background" />
2 Create this file \android\app\src\main\res\values\colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="gradientstart">#3587d0</color>
<color name="gradientend">#36f1d3</color>
</resources>
3 Finally, create this file \android\app\src\main\res\drawable\gradient_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#color/gradientstart"
android:endColor="#color/gradientend"
android:angle="90"/>
</shape>
For Android first define two color in your colors.xml:
<color name="gradientstart">#888888</color>
<color name="gradientend">#111111</color>
then in \android\app\src\main\res\drawable\launch_background.xml just replace this:
<item android:drawable="#color/background" />
to this:
<gradient android:startColor="#color/gradientstart" android:endColor="#color/gradientend" android:angle="315"/>
and for ios according to this question
If your gradient is a simple vertical or horizontal gradient, and
you’re really concerned about asset size, you can define a very narrow
image and then add an image view with “scale to fill” content mode.
But these images are so small anyway, the amount of space saved will
be negligible, so I’m not sure it’s worth worrying about.
I found use of flutter_native_splash much more easy and direct. Here's a link on the steps to creating one. First design your desired gradient as an image and instead of adding color, add a background_image on the pubspec.yaml file.
Something like:
flutter_native_splash:
image: ""
background_image: "assets/my_splash_background.png"
Following the instructions at Google Developers site, I sucessfuly created my splash screen.
Using the meta-tag:
<meta-data
android:name="android.support.customtabs.trusted.SPLASH_SCREEN_BACKGROUND_COLOR"
android:resource="#color/colorPrimary"/>
We can display a color in our app, but can we display a gradient?
I have tried to create a xml gradient and then reference it with android:background instead of android:resource, but it didn't work.
My gradient.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient
android:type="linear"
android:startColor="#color/color1"
android:endColor="#color/color2"
android:angle="135" />
</shape>
My colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color1">#fafafa</color>
<color name="color2">#212121</color>
</resources>
And the snipet added in the manifest.
android:background="#drawable/gradient"
As said, I just want to be able to use splash screen gradients using native TWA meta-tags, if possible. I got errors when I try to install the .apk (invalid package).
Reference link: Google Dev Splash Screen
Only flat colors can be used as background for a Trusted Web Activity splash screen and drawables are not currently accepted in the Splash Screen.