rey5137 / material

A library to bring fully animated Material Design components to pre-Lolipop Android.
http://rey5137.com/material/
Apache License 2.0
6k stars 1.32k forks source link

android.content.res.Resources$NotFoundException #177

Open codezjx opened 9 years ago

codezjx commented 9 years ago

android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f0101bd a=6} at android.content.res.Resources.loadColorStateList(Resources.java:2337) at android.content.res.TypedArray.getColorStateList(TypedArray.java:343) at com.rey.material.app.Dialog.applyStyle(Dialog.java:207) at com.rey.material.app.DatePickerDialog.applyStyle(DatePickerDialog.java:74) at com.rey.material.app.Dialog.init(Dialog.java:160)

Show this crash error if my app don't use "Theme.AppCompat.Light.DarkActionBar", when I change to this, everything works fine. Why?

laszlo-galosi commented 9 years ago

Yes I have the same issue, and my Base.Theme is "Theme.AppCompat.Light.NoActionBar" and it's required to be that, because I use Material Design library Toolbar. Is there any way to fix this?

laszlo-galosi commented 9 years ago

My stacktrace is: android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x7f010204 a=3} at android.content.res.Resources.loadColorStateList(Resources.java:2068) at android.content.res.TypedArray.getColorStateList(TypedArray.java:342) at com.rey.material.app.Dialog.applyStyle(Dialog.java:251) at com.rey.material.app.DatePickerDialog.applyStyle(DatePickerDialog.java:74) at com.rey.material.app.Dialog.init(Dialog.java:176) at com.rey.material.app.Dialog.(Dialog.java:120) at com.rey.material.app.DatePickerDialog.(DatePickerDialog.java:63) at com.rey.material.app.DatePickerDialog$Builder.onBuild(DatePickerDialog.java:814) at com.rey.material.app.Dialog$Builder.build(Dialog.java:1498)

laszlo-galosi commented 9 years ago

Looks like, it's casued by the default di_actionTextColor style property which in default refers to the theme, ?attr/colorControlActivated and it requires a colorStateList, and I only used a simple color in my theme. And it looks like, there are problems with attributes, which uses theme specific attribute refrences for ex: dp_headerPrimaryColor, dp_headerSecondaryColor, dp_selectionColor etc. uses "?attr/colorPrimary" in the Material.App.Dialog.DatePicker.Light style. So I define a custom style derived from the above, and overwrite these problematic attributes with direct color references.