Issue
I'm trying to use a color from a variable defined like this(like the primary color from this variable)
val DefaultLightColors = lightColors(
primary = Color(0xFF2052EF),
primaryVariant = Color(0xFF0030cc),
secondary = Color(0xFFff9911))
in xml
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/</item>
I know they're a lot of questions regarding colors but I haven't found one addressing this.
Solution
Maybe you want to check out the colors.xml in the values dir. There you can list all the colors you need, then you can get them in the code by R.colors.** or in the style.xml with @color. Hardcoding colors in the code is not really best practice since its hard to maintain.
A snippet of a colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
<color name="yellow">#FFFF00</color>
<color name="fuchsia">#FF00FF</color>
<color name="red">#FF0000</color>
<color name="silver">#C0C0C0</color>
I hope this is what are you looking for
Answered By - flappo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.