You need to use a Theme.Appcompat Theme (or Descendant) with this Activity

Asked

Viewed 753 times

0

I’m having this problem when running my app on an android 4.4. I have spent all day looking for solutions, but nothing works and I can not find errors in my code. I thank you from now on any help!

Exception

xml style.:

<resources>

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

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

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

v21 style.xml:

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

    <!--<item name="android:windowDrawsSystemBarBackgrounds">true</item>-->
    <!--faz o drawer aparecer por baixo do status-->
    <!--<item name="android:statusBarColor">@android:color/transparent</item>-->

    <item name="android:dialogTheme">@style/AppTheme.DialogStyle</item>
    <item name="android:alertDialogTheme">@style/AppTheme.DialogStyle</item>

    <item name="windowActionModeOverlay">true</item>
    <item name="windowActionBarOverlay">true</item>
</style>

<style name="AppTheme.DialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:colorAccent">@color/colorAccent</item>
</style>

manifest:

<application
    android:allowBackup="false"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="false"
    android:theme="@style/AppTheme"

    <activity
        android:name=".controller.activitys.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:theme="@style/AppTheme.NoActionBar"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

    See if this reply resolves.

  • In a way your comment helped me find the solution. Thank you! The solution was to mirror the 2 style.xml files and put the unique features of the 21+ api only in v21/style.xml

1 answer

0

Instead of:

<activity
        android:name=".controller.activitys.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:theme="@style/AppTheme.NoActionBar"

You must put:

<activity
        android:name=".controller.activitys.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:theme="@style/Theme.AppCompat"

Then you take the Actionbar via code if you prefer.

  • Your solution ended up giving me more problems, because Apptheme.Noationbar contains the settings of Activity and also with problems to use the Toolbar contained in Activity

Browser other questions tagged

You are not signed in. Login or sign up in order to post.