[MaterialButton] android.view.InflateException:
See original GitHub issueDescription: I’m trying to design a button for my view holder, but the application throws an exception. E/ThemeUtils: View class com.google.android.material.button.MaterialButton is an AppCompat widget that can only be used with a Theme.AppCompat theme (or descendant).
android.view.InflateException: Binary XML file line 149 in
Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
Source code:
<com.google.android.material.button.MaterialButton
android:id="@+id/call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="12dp"
android:onClick="@{()->item.onClickCall()}"
android:text="@string/call"
android:textColor="@color/colorPrimary"
app:backgroundTint="@color/white"
app:cornerRadius="6dp"
app:icon="@drawable/ic_call"
app:iconTint="@color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_view_desc"
app:strokeColor="@color/colorPrimary"
app:strokeWidth="1dp" />
Android API version: 30
Material Library version: implementation “com.google.android.material:material:1.2.1”
Device: Pixel 2 XL
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Error inflating com.google.android.material.button ... - GitHub
MaterialButton Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.material.button.
Read more >Using Material Button gives ClassNotFound runtime error
As I have a lot of support elements I had to change the widget in the XML file to "android.support.design.button.MaterialButton" which solved ...
Read more >MaterialButton - Android Developers
A convenience class for creating a new Material button. This class supplies updated Material styles for the button in the constructor.
Read more >Error inflating class > com.google.android.material ...
So I use SwitchMaterial in one layout: ... android.view.InflateException: Binary XML file line #324: Binary XML file line #324: Error inflating class ...
Read more >[Solved]-Binary XML file line #10: Error inflating class com ...
Coding example for the question Binary XML file line #10: Error inflating class com.google.android.material.button.MaterialButton for API Level ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
ApplicationContext
has not the app theme.Wow, good to know that!!! That means I need the activity/fragment context. Many thanks bro. 😄