Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
<resources> <drawable name="red">#7f00</drawable> .... <color name="solid_red">#f00</color> ..... </resources>
这是来自 android samples 目录的 colors.xml 的一部分。
<drawable>现在我的问题是,在tag 和tag中定义颜色有什么区别<color>?
<drawable>
<color>
基本上什么都没有。它们都创建了一个资源,该资源是一个“颜色”值,具有 32 位颜色。一个只是可绘制的子类型,一个是颜色子类型。当您从资源中检索 Drawable 时,如果资源实际上是一个颜色常量,它知道如何为此创建一个 Drawable 对象。