简体   繁体   中英

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

I'm trying to create my splash screen with native android, i'm using flutter, and my android project is in kotlin, i'm trying to create new color to android, because i need specific hexa color, but i can't create my own color, when i try, the flutter say can't recognize the name of color.

Thats is some of attempts:

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

The file is 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>

The file is android -> app -> res -> drawable -> launch_background.xml

When the item drawable is color holo_blue_light its works fine because its android color already, but when i try put the color "goiaba" doesn't works...

Thats is the message of error: 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

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