繁体   English   中英

反正有没有用flutter项目在android中创建新颜色?

[英]Is there anyway to create new color in android with flutter project?

我正在尝试使用原生 android 创建我的启动画面,我正在使用 flutter,我的 android 项目在 kotlin 中,我正在尝试为 android 创建新颜色,因为我需要特定的 hexa 颜色,但我不能创建我自己的颜色,当我尝试时,颤振说无法识别颜色的名称。

这是一些尝试:

<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>

    </style>
        <color name="goiaba">#e1635a</color>

</resources>

该文件是 android -> app -> res -> values -> styles.xml

<!-- 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" />

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

    </item>
</layer-list>

该文件是 android -> app -> res -> drawable -> launch_background.xml

当可绘制项目的颜色为 Holo_blue_light 时,它可以正常工作,因为它的 android 颜色已经是,但是当我尝试放置颜色“goiaba”时,它不起作用......

这就是错误信息:android/app/src/main/res/drawable/launch_background.xml:13: AAPT: error: resource android:color/goiaba not found。

我发现如何使用 flutter 项目在 android 中创建新颜色,我需要在 PROJECT/android/app/src/main/res/values/ 中创建 colors.xml 并使用 @color/COLOR_NAME 添加

不创建colors.xml文件也没关系,你第一次尝试没有成功的原因是你使用了@android:color/goiaba而不是@color/goiaba

暂无
暂无

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

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