简体   繁体   English

Delphi XE7 Android 启动画面 - 背景色

[英]Delphi XE7 Android splash screen - background color

I can see Delphi XE7 comes with splash/startup image support for Android.我可以看到 Delphi XE7 为 Android 提供了启动/启动图像支持。

However, when I choose to center the image (which looks best) Delphi shows black color around it.但是,当我选择将图像居中(看起来最好)时,Delphi 在它周围显示黑色。 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.如果您想用与图像相同的背景颜色填充黑色背景,则必须使用 9patch 图像。 To make 9patch pngs use NinePatch (included in android sdk)要制作 9patch png,请使用NinePatch (包含在 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)取消选中 splash_image_def.xml(不部署)
  2. rename your splash_image.png to splash_image_def.9.png将您的 splash_image.png 重命名为 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: Android 上的 Splash 图像有 4 种不同的可能尺寸:

  • 426 x 320 426 × 320
  • 470 x 320 470 × 320
  • 640 x 480 640 x 480
  • 960 x 720 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.因此,根据您支持的设备,您最多应该有 4 张与这些尺寸匹配的图像,背景颜色是您想要的。 Set it up to fill the entire screen, and make sure you're not using transparency.将其设置为填满整个屏幕,并确保您没有使用透明度。 For Splash Gravity , select the fill option.对于Splash Gravity ,选择fill选项。

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 . colors.xmlsplash_image_def.xml You will find these in the Android/Debug/ (or Android64/Debug/ ) folder of your project.您将在项目的Android/Debug/ (或Android64/Debug/ )文件夹中找到这些。 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.Project|Deployment ,取消勾选这些项目并为您制作的副本创建新条目,确保将它们部署到同一位置。 You will end up with two entries for Debug and Release .您将最终获得DebugRelease两个条目。

Edit colors.xml and add the new color that you want like so编辑colors.xml并像这样添加你想要的新颜色

<?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.在这里,我添加了 logoblue 颜色。 Next edit splash_image_def.xml and change @android:color/black to @color/logoblue .接下来编辑splash_image_def.xml并将@android:color/black更改为@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,要更改默认的黑色启动画面,只需在调试文件夹中打开 splash_image_def.xml,

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.注意:在 RAD Studios 中无需更改源代码、布局或任何内容即可构建它。 Just edit the file xml with notepad, save it, then rebuild.只需用记事本编辑文件xml,保存,然后重建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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