Here's the code in 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="#android:color/black" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/applogo" />
</item>
</layer-list>
I have changed the color to 'black'- yet I get a white splash screen, neither do the logo shows up.
I have placed the logo (png) in the drawable folder. Can anyone help me with this?
first, you need 2 files to make this work, first are the files in the drawable and drawable-v21 folders they should have
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/background_color" />
<item>
<bitmap android:gravity="center" android:src="#mipmap/launch_icon" />
</item>
</layer-list>
#color/background_color
is a custom color style for android which you would have to create it next
#mipmap/launch_icon
is a custom icon image you have in your mipmap folders you can create the sizes by using https://appicon.co
and the second file will create as a colors.xml in the values and values-night folder this file will carry the color you want to use
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background_color">#000000</color>
</resources>
I think you want to remove the white screen at app boot time. Check This library, you can use color or logo image anything else instead of the white screen.
Click this Link
Here is the Preview
for android
open launch_background.xml file inside the Res folder and add one new splash screen image in the drawable folder. Now change code in two places. See tutorial example here
Edit this launch_background.xml by adding a new item and set the splash screen image as an item value.
For iOS app
Open flutter project on Xcode for Adding splash screen to flutter ios app. To open the iOS module on Xcode, open android studio and on the top menu select tools. Go to flutter –> open ios module on Xcode.
On Xcode window, Click on Runner-> Runner -> Assets.xcassets folder. Here you can see LaunchImage paste your splash screen image with all three different dimensions in this folder.
Open LaunchScreen.storyboard
Again on the left side menu just below the Assets.xcassets folder, you will see LaunchScreen.Storyboard. Click on view controller scene -> view controller -> view. Note: – select (click on ) view only don’t click on LaunchImage. You already paste the new splash screen in the LaunchImage folder in the previous step. So you will see the same new image here in this window. When you select (click on ) view then on the right side window you can see options to change view settings like content mode, background, alpha etc. change the background colour as you want and set content mode to scale to fill.
Adjust Splash Screen
You can adjust the splash screen position, size & background colour on the same window. Just click on launchImage OR select the image on the preview window. You can resize the image and can adjust the image position. On the Right side window, you can make another set as well.
iOS App Splash Screen is Ready.
Now flutter white splash screen problem has been resolved successfully for both android and iOS. You can change the flutter splash screen background color as per your requirements.
Related
Currently using the layer-list to achieve a splash screen with a drawable at the center. The app is targetting API 23+ so using bitmap is not mandatory unless it's necessary for what am trying to do. Basically I'm trying to pull off something similar to WhatsApp's new splash screen where the company reference is placed at the bottom of the screen.
But for some reason, the second image is not being shown at all even though it's visible in the Android Studio preview distorted. What I have currently is:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/black700" />
<item
android:drawable="#drawable/ic_app_icon"
android:gravity="center" />
<item
android:drawable="#drawable/ic_company_mark"
android:gravity="bottom|center" />
</layer-list>
As stated in the comments I've noticed that the bottom item depends on the phone resolution on some phones. Why it depends on the resolution, I don't know.
To work around you can add padding at the bottom
<item android:bottom="50dp">
for your bottom item in your layer-list and it will show up.
I haven't found a way to dynamically set the value depending on something and therefore used a value which "looks good" for most display resolutions.
I am trying to implement a splash screen for my application, following the usual method; defining a new theme inside the styles XML file that places a drawable as windowBackground and reverting to the main theme in the Activity's onCreate().
However, I am having problems when showing the logo I developed in Photoshop: I exported it as a 144x144 PNG file, created an Image Asset with it (replacing the standard ic_launcher drawable) but when I try to visualize it inside an XML file, this image is displayed instead
Screenshot
Any ideas? I've also tried to create a vector asset from the .psd but nothing is shown either...
https://romannurik.github.io/AndroidAssetStudio/
use this link to generate your icon. It will work.
Change the code and so on
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/your_background"/>
<item android:drawable="#drawable/your_image">
</item>
</layer-list>
I have integrated splash screen into my app from android manifest I gave it a newly made SplashTheme and whenever the onActivityCreated called I change it to the one that is needed. Now , in splash.xml file which you can see below:
<item>
<color android:color="#color/colorPrimary" />
</item>
<item>
<bitmap
android:gravity="center"
android:src="#mipmap/ic_launcher" />
</item>
I put my launcher ic_launcher in the center but when the device in which the app is installed uses round icons the splash screen still shows the "original" icon. I know because I put here ic_launcher instead of ic_launcher_round but I would like to make this part dynamic, to recognize if the devices uses round icons put ic_launcher_round and the opposite.
Here is the part of my AndroidManifest.xml:
Afaik, you cannot achieve the behavior you expect, simply because there does not exist an API, that would provide you whether current launcher uses round icon or a default icon.
Instead, you should construct your splash screen in a way, that is not dependent on the default launcher implementation of the device. Normally, you should have the same image regardless launcher uses round or normal icons.
Leave launcher icons aside and create a resource specifically for splash screen.
You might be thinking this question is a duplicate of this one. But since then, Android Studio has been updated and the solution given there is not working anymore.
Why are we forced to have a background when creating an Image Asset? What's the reason behind this? How we are supposed to change the launcher_icon without having any background? I don't see any option to disable the background in Image Asset.
Alternatively, I use an empty background but this doesn't work in Full Bleed Layers:
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
</vector>
Or, just remove the background, but this will add a white background in your launcher_icon:
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Remove the background here and leave the foreground -->
<foreground android:drawable="#drawable/ic_launcher_foreground"/>
</adaptive-icon>
Or, change icon type into Legacy Only and set shape to none:
Still, there's a white background in the launcher icon when installed.
So how can I get a transparent background or none for that matter, for my Launcher icon using Image Asset?
It is not a problem of the icon you created with Android Studio, but it's a problem related to your specific device you're testing the application on.
In fact, in the Image Asset if you specify the Shape to None, you get a trasparent background.
To address your problem, please try to use a different Home theme, like the Nova Launcher; you can change the home theme in Settings - Home.
I see that i can set 2 images in one ImageView in android using a new Drawable XML file under resources, called for this example my2img.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/img1" />
<item android:drawable="#drawable/img2" />
</layer-list>
and Apply to the imageView.
testimage.setImageDrawable(getResources().getDrawable(R.layout.my2img));
But how can i access one of the 2 images from Java code ?
For example on runtime i want to show the first image full overlapped by a only a slice of the other image, another moment the full second image..and so on... just like a progress bar behaviour.
Is there any code sample ?