Android XML: RuntimeException: Failed to resolve attribute at index 6
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>
Had the same issue because have used getApplicationContext()
instead of Activity
to retrieve LayoutInflater
and inflate item view for list adapter.
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
.
Make sure your theme .
My theme :
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#1565C0</item>
<item name="colorAccent">#E91E63</item>
</style>