Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Android Studio highlight "Theme" red in styles.xml?

Red highlight means Cannot resolve symbol 'Theme'

enter image description here

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.

like image 465
codelovesme Avatar asked Aug 12 '14 13:08

codelovesme


People also ask

What is theme XML in Android Studio?

A theme is a collection of attributes that's applied to an entire app, activity, or view hierarchy—not just an individual view. When you apply a theme, every view in the app or activity applies each of the theme's attributes that it supports.

What is the use of style .XML in Android?

Styles in Android allow you to define the look and feel, for example colors and fonts, of Android components in XML resource files. This way you have to set common style attributes only once in one central place.

How do I change the color of my style on Android?

Here's how to change UI colors in Android 12 or higher:Open the Settings. Go to Wallpaper & style. You have two main options. You can let Android pick the system colors based on the wallpaper.

Which XML file defines all themes of the Android project?

To define a style or a theme, save an XML file in the /res/values directory of your project. The root node of the XML file must be the <resources> tag. To define a style or a theme, define an entry with the style tag and define the name attribute.


2 Answers

This is how I solved it:

  1. Go to your project directory (or to Project View)
  2. Go into the .idea directory
  3. Remove caches and libraries directories
  4. File -> Invalidate Caches / Restart

Should be OK now.

like image 160
Ognyan Avatar answered Nov 14 '22 23:11

Ognyan


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.

like image 35
codelovesme Avatar answered Nov 15 '22 00:11

codelovesme