为什么Android Studio会突出显示“主题”在styles.xml中为红色? [英] Why does Android Studio highlight "Theme" red in styles.xml?
问题描述
红色突出显示表示无法解析符号'Theme'
以下是一些配置:
styles.xml
< style name =AppBaseThemeparent =Theme.AppCompat.Light >
<! -
在较新的API级别中可用的主题自定义可以在
res / values-vXX / styles.xml中进行,而与
向后兼容相关的自定义可以转到这里。
- >
< item name =android:windowNoTitle> true< / item>
< / style>
<! - 应用程序主题。 - >
< style name =AppThemeparent =AppBaseTheme>
< item name =android:windowNoTitle> true< / item>
< / style>
。
AndroidManifest.xml p>
< uses-sdk android:minSdkVersion =8android:targetSdkVersion =19/>
...
机器人:主题= @风格/ AppTheme >
。
build.gradle p>
依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
编译'com.android.support:appcompat-v7:19.0.0'
}
...
android {
compileSdkVersion 19
buildToolsVersion '20 .0.0'
defaultConfig {
applicationId'com.mobile.slider'
minSdkVersion 8
targetSdkVersion 19
。
MainActivity.java
公共类MainActivity扩展活动{
手机Nexus 4的Android版本是
4.4.4。即使没有构建问题,NoTitleWindow模式不适用于另一款拥有2.3.3 android版本的手机。
我已经将appcompatv7项目添加为模块,但我忘记将其显示给我的应用程序模块。只是我已经意识到并修复了。现在它不再提醒我。感谢您的回复,tritop。
Red highlight means Cannot resolve symbol 'Theme'
Here are some configurations :
styles.xml
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<item name="android:windowNoTitle">true</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowNoTitle">true</item>
</style>
.
AndroidManifest.xml
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" />
...
android:theme="@style/AppTheme">
.
build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.0.0'
}
...
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.mobile.slider'
minSdkVersion 8
targetSdkVersion 19
.
MainActivity.java
public class MainActivity extends Activity {
It is working nice with my phone Nexus 4 whose android version is
4.4.4. Even though, There is no build problem, NoTitleWindow Mode doesn't work for
another phone which has 2.3.3 android version.
I had added appcompatv7 project as a module but I have forgotten to show it to my application module. Just I have realized and fixed. Now it doesn't alert me anymore. Thanks for your reply, tritop.
这篇关于为什么Android Studio会突出显示“主题”在styles.xml中为红色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!