0

I am new to android development and was developing an overflow menu. For that I had to change the theme of my app so that the action bar that contains the overflow menu was visible.

But android studio is not rendering any of the themes with the action bar.

I searched the internet for solutions and found one on stackoverflow that said I had to update my res/values/styles.xml file. I updated the tag named AppTheme, but it didn't solve my problem.

I tried to invalidate cache and restart but still not solved. I also tried to clean the project and rebuild it. Nothing worked.

I am attaching a screenshot of the errors. Please Help.

enter image description here

Here is my styles.xml file:

 <resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.naveenjain.test3">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
Ayusch
  • 417
  • 7
  • 17

1 Answers1

0

According to issue: You need to use a Theme.AppCompat theme (or descendant) with this activity you need to follow these steps:

The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending ActionBarActivity which requires the AppCompat theme to be applied.

Change the Java inheritance from ActionBarActivity to Activity and leave the dialog theme in the manifest as it is.

Check link above for more solutions

Hope it help

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94
  • Although my main activity was extending from AppCompatActivity, but when I changed it to extend from Activity it still didn't solve the problem. I am a newbie in android development so it would be helpful if you list the steps of the solution. Thanks – Ayusch Jan 04 '16 at 11:45
  • add `build.gradle` file (you may have problem with dependencies) and if possible Java class – piotrek1543 Jan 07 '16 at 08:17