![](/img/trans.png)
[英]No option to create New Flutter Project on Android Studio
[英]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.