首页 > 解决方案 > colors.xml 和多个模块

问题描述

我在公共模块中有 3 个模块(common、app1、app2) 我有一个布局,我想在 app1 中为黑色,在 app2 中为白色。

布局.xml

<LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:baselineAligned="false"
        android:orientation="horizontal"
        android:padding="16dp"
        android:background="@color/myColorBackground"
        android:weightSum="4">
...

App1 颜色.xml

<ressources>
   <color name="myColorBackground">#fff</color>
</resources>

App2 颜色.xml

<ressources>
   <color name="myColorBackground">#000</color>
</resources>

当我尝试构建应用程序时,我遇到了崩溃。有没有使用这样的颜色的解决方案?

标签: androidandroid-viewandroid-xmlandroid-resources

解决方案


我通过<color name="myColorBackground"/>在我的公共模块中添加找到了一种解决方法,现在一切正常


推荐阅读