Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView

前端 未结 3 1370
野性不改
野性不改 2021-01-18 03:27

I\'m trying to add BottomNavigationView to my layout with this library:

implementation \'com.google.android.material:material:1.0.0\'

相关标签:
3条回答
  • 2021-01-18 04:12

    Your problem is related with the resources you are using on your BottomNavigationView widget.

    One of these is the issue:

    app:itemBackground="?colorPrimary"
    app:itemIconTint="@drawable/bottom_navigation_selector"
    app:itemTextColor="@drawable/bottom_navigation_selector"
    

    Check if your drawables exits in both res/drawable and any res/drawable-vXX you might have.

    0 讨论(0)
  • 2021-01-18 04:25

    Make sure that you put drawables in res/drawable folder and not in res/drawable-v24. I had a similar problem and by moving files to the res/drawable folder the error has gone.

    0 讨论(0)
  • 2021-01-18 04:26

    Instead of

    app:itemBackground="?colorPrimary"
    

    set

    app:itemBackground="@color/colorPrimary"
    

    Edit: also check that the drawables are in res/drawable folder and not in a folder like res/drawable-v21

    0 讨论(0)
提交回复
热议问题