简体   繁体   中英

Delphi XE7 Android splash screen - background color

I can see Delphi XE7 comes with splash/startup image support for Android.

However, when I choose to center the image (which looks best) Delphi shows black color around it. I would prefer white since it fits better with the image and color theme of the app. There does no appear to be an opion for background color where you set splash/startup images.

How can I change this color?

If you want fill the black background with the same background color from your image you must use 9patch images. To make 9patch pngs use NinePatch (included in android sdk)

Once you hace the images, add to your project and set up like this:

  • splash tile mode: disabled
  • splash gravity: center

Then go to project -> deployment:

  1. Uncheck splash_image_def.xml (to not deploy)
  2. rename your splash_image.png to splash_image_def.9.png

There is no background color property of splash images because this is supposed to be a part of the image. There are 4 different possible sizes for Splash Images on Android:

  • 426 x 320
  • 470 x 320
  • 640 x 480
  • 960 x 720

So, depending on your supported devices, you should have up to 4 images matching these sizes, with the background color being whatever you wish. Set it up to fill the entire screen, and make sure you're not using transparency. For Splash Gravity , select the fill option.

If you are just wanting to change the background color of the splash screen, you can modify two files. colors.xml and splash_image_def.xml . You will find these in the Android/Debug/ (or Android64/Debug/ ) folder of your project. These get recreated each time you deploy your application so you will need to make backup copies of them.

In Project|Deployment , untick these items and create new entries for the copies you have made, making sure that you deploy them to the same location. You will end up with two entries for Debug and Release .

Edit colors.xml and add the new color that you want like so

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <color name="notification_accent_color">#000000</color>
    <color name="logoblue">#0094ff</color>
</resources>

Here I've added the logoblue color. Next edit splash_image_def.xml and change @android:color/black to @color/logoblue . It should look somewhat like the following

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
<item android:drawable="@color/logoblue" />
<item>
<bitmap
  android:src="@drawable/splash_image"
  android:antialias="true"
  android:dither="true"
  android:filter="true"
  android:gravity="center"
  android:tileMode="disabled"/>
</item>
</layer-list>

There might be a simpler way of doing this, but this is what I've come up with through a bit of trial and error.

to change default black splashscreen, just open splash_image_def.xml at debug folder,

and change "black" to white if you want change it to white, like this

<item android:drawable="@android:color/white" />

Note : Build it with no change at source code, layout or anything at RAD Studios. Just edit the file xml with notepad, save it, then rebuild.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM