I have a very simple text:
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/app_name" android:textSize="20sp" android:textColor="@style/basic_text_color" android:layout_gravity="center" android:id="@+id/toolbar_title" />
What style @ style / basic_text_color is the color that I wanted to reuse in the application, so I create app_colors.xml in the values folder:
<?xml version="1.0" encoding="utf-8"?> <resources> <style name="basic_text_color" parent="@android:style/TextAppearance"> <item name="android:textColor">#ff932e</item> </style> </resources>
The application compiles successfully, but then whenever it runs, it freezes and the following error will be requested in LogCat:
FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aaa/com.example.aaa.activity.MainActivity}: android.view.InflateException: Binary XML file line
So it looks like the error here is: "Resource is not ColorStateList (color or path): TypedValue {t = 0x1 / d = 0x7f0b0124 a = -1 r = 0x7f0b0124}" ...
Did I use the font style incorrectly? Or are any other things going wrong? Thanks!
source share