我在模块中定义了以下样式,我想将其用作 Activity 的主题
Android 模块的 styles.xml:
<resources>
<style name="MyTheme" parent="android:Theme.Light.Panel"></style>
</resources>
Android 应用程序的 AndroidManifest.xml:
<activity android:name="MyActivity" android:theme="@style/MyTheme"> ... </activity>
我正在使用 IntelliJ,但出现编译错误
android-apt-compiler: AndroidManifest.xml:26: error: Error: No resource found that matches the given name (at 'theme' with value '@style/MyTheme').
如何在我的主应用程序中引用模块的 jar 中的样式?
谢谢。
最佳答案
我刚刚解决了这个问题,项目是这样的:
- 你有模块(例如moduleLib)
- 你有一个模块(例如moduleMain)
- moduleMain依赖于moduleLib,moduleLib的一些主题是 在 moduleMain 中引用
我做了什么:
1.将moduleLib设置为库项目
(menu->Project Structures...->Modules->moduleLib->facet Android -> 检查“Is Library project”
2 设置moduleMain依赖于moduleLib
2.1 进入moduleMain的设置(步骤同上)
2.2 切换到“Dependencies”
2.3 点击“+”,选择“module Dependency”添加moduleLib
2.4 将“scope”改成Compile(我试过获取Provided,但那时我不能使用主题)
对我有用
关于java - 如何使用 IntelliJ 引用 Android 模块中定义的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16956774/