Android error for `@android: style / Theme.Material.Light`

Hi, I was building one Android sample app with some material design concepts. I started with https://developer.android.com/training/material/theme.html . I am using eclipse. I added the appcompat_7 support library in the library section of my project. Then, when I try to apply the following topic.

<style name="AppTheme" parent="@android:style/Theme.Material.Light"> </style> 

This gives me the following runtime error:

 11-12 11:32:30.416: E/AndroidRuntime(21375): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidmaterialdesignapi/com.example.androidmaterialdesignapi.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. 

My activity extends ActionBarActivity . I am doing something wrong. Help is needed. Thanks. Is there a good example to study material design?

+5
source share
1 answer

Yes, when you use the ActionBar action as parent activity, you need Theme.AppCompat to be your parent style for your customized theme.

Replace your line as follows:

 <style name="AppTheme" parent="@style/Theme.AppCompat"> 

instead of this

 <style name="AppTheme" parent="@android:style/Theme.Material.Light"> 

Hope this helps.

+4
source

Source: https://habr.com/ru/post/1206689/


All Articles