【问题标题】:Is there anyway to create new color in android with flutter project?反正有没有用颤振项目在android中创建新颜色?
【发布时间】:2020-07-09 07:38:00
【问题描述】:

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

这是一些尝试:

<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.

【问题讨论】:

    标签: android flutter kotlin


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2020-01-28
        • 2019-03-07
        • 2020-02-02
        • 2022-09-30
        • 1970-01-01
        • 1970-01-01
        • 2022-06-30
        • 2020-02-18
        相关资源
        最近更新 更多