Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheriting from Theme.AppCompat*

Currently working on migrating to ActionBar in the support libraries. Currently trying to migrate my old themes to inherit from Theme.AppCompat.Light.DarkActionBar but it isn't going very smoothly.

It is fine if I apply the theme in the manifest as such:

<activity
    android:name="com.fitsby.LoginActivity"
    android:screenOrientation="portrait"
    android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
</activity>

But I get a runtime error, stating that LoginActivity(subclass of ActionBarActivity) must have a theme which inherits from Theme.AppCompat, when I do the following: in styles.xml:

<style name="AppTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="android:typeface">sans</item>   
</style> 

and in the manifest:

<activity
    android:name="com.fitsby.LoginActivity"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme" >
</activity>

Any ideas why that is happening? I do not see a problem, since AppTheme clearly inherits from one of the AppCompat Themes.

like image 472
Brent Hronik Avatar asked Jul 31 '13 14:07

Brent Hronik


1 Answers

If you have different values folder in your application, for different API levels, make sure that each of those themes from the folders extend from the required Theme.AppCompat.* themes.

like image 176
user Avatar answered Sep 29 '22 16:09

user