如何将文本添加到flutter android中的默认启动屏幕



我正试图在Flutter应用程序中的launch_background.xml中添加android默认启动屏幕启动图标的底部文本>androidappsrcmainresdrawable

<?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="@mipmap/launch_image" />
</item>
</layer-list>

到目前为止,我只是尝试在item标签下面添加一个标签标签,但没有成功。

可绘制文件中使用的layer-list是将多个可绘制文件层叠在一起的一种方法。您不能将纯文本添加到图像中,但可以定义一个新的可绘制对象,即文本,然后将图层添加到列表中。

另一种选择是:

打开Paint或任何图像编辑工具,编写文本并将文件保存为png图像

在drawables中导入png文件,并将其添加到<layer-list>中,作为徽标/图标下方或上方的item

<item android:bottom="50dp">根据设置位置

<?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/colorPrimary"/>
<item>
<bitmap
android:gravity="center"
android:src="@drawable/icon"/>
</item>
<item android:bottom="50dp">
<bitmap
android:gravity="center"
android:src="@drawable/myTextImage"/>
</item>
</layer-list>

无法在启动屏幕上添加文本。这里的一个解决方法是在启动屏幕上使用的图像上添加文本。

要添加可在启动屏幕上使用的新颜色,请在/android/app/src/main/res/values/colors.xml 中创建colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="color_name">#ff0000</color>
</resources>

现在,您可以通过在launch_background.xml 上添加此颜色来使用该颜色

<item>
<color android:color="@color/color_name">
</item>

最新更新