Android Xml: Runtimeexception: Failed To Resolve Attribute At Index 6
Solution 1:
Ran into this problem myself. It's because my app isn't using AppCompat yet, still just the regular support FragmentActivity
. This means that FloatingActionButton
was looking for two theme attributes and it couldn't find them.
Specifically adding in these missing attributes made it work for me without the need to start using AppCompat.
<LinearLayout...xmlns:app="http://schemas.android.com/apk/res-auto".../><android.support.design.widget.FloatingActionButton...app:backgroundTint="@color/{some color statelist}"app:rippleColor="@color/{some color statelist}"... /></LinearLayout>
Solution 2:
Had the same issue because have used getApplicationContext()
instead of Activity
to retrieve LayoutInflater
and inflate item view for list adapter.
Solution 3:
You can solved this problem by using Theme.AppCompat.Light
as your activity's parent theme.
add:
The reason is that one of the default style using inner in FloatingActionButton is declare like this:
the backgroundTint is refer to another attribute colorAccent which should be measure declared in our theme, otherwise, the exception might be throw.
But
colorAccent
is declared in AppCompat Theme and did not declared in the sdk default Theme.To measure that we can using the design lib correctly in running, one of the easy way is to measure the using of AppCompat Theme like Theme.AppCompat.Light
.
Solution 4:
Make sure your theme .
My theme :
<!-- Base application theme. --><stylename="AppTheme"parent="Theme.AppCompat.Light.DarkActionBar"><!-- Customize your theme here. --><itemname="colorPrimary">#2196F3</item><itemname="colorPrimaryDark">#1565C0</item><itemname="colorAccent">#E91E63</item></style>
Solution 5:
I was using a custom attribute in attrs.xml and a customview. I ran into this problem as I didn't specify theme:
attribute in the custom view. Quick look of how the files look
attrs.xml
<resources><attrname="textColorPrimary"format="reference" />
...
</resources>
customview.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tvText"
style="@style/TitleBlackThin"
android:theme="@style/AppTheme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="16dp"
android:text="@string/text" />
In my styles.xml, I extended my style to use AppTheme
<resources><stylename="AppTheme"parent="Theme.AppCompat.Light.NoActionBar"><itemname="textColorPrimary">@color/black</item></style>
...
<stylename="TitleBlackThin"><itemname="android:textSize">20sp</item><itemname="android:fontFamily">sans-serif-light</item><itemname="android:textStyle">normal</item><itemname="android:textColor">?textColorPrimary</item></style>
...
</resources>
The culprit here was custom attribute ?textColorPrimary. As I didn't define AppTheme in the customview, it wasn't able to determine how to load textColorPrimary. By android:theme="@style/AppTheme", this got fixed))
Post a Comment for "Android Xml: Runtimeexception: Failed To Resolve Attribute At Index 6"