개발/안드로이드 개발
java.lang.IllegalArgumentException: This component requires that you specify a valid android
룬아님
2020. 3. 12. 13:20
BadgeDrawable과 같은 Material에 포함되어 있는 뷰를 사용할때에
App theme를 Theme.AppCompat로 사용하고 있을 때 생기는 크래시이다.
Material view들을 사용하기 위해서는
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
위와 같이 MaterialComponents theme를 상속받아야 한다.
하지만 MaterialComponents에 의해 작동방식이나 뷰의 모양이 변할 수 있고 이를 원치 않을 때에는
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorAccent</item>
<item name="colorAccent">@color/colorPrimaryDark</item>
</style>
Bridge를 사용하면 된다.
https://material.io/develop/android/docs/getting-started/
Getting Started - Material Components for Android
Getting started with Material Components for Android 1. Depend on our library Material Components for Android is available through Google’s Maven Repository. To use it: Open the build.gradle file for your application. Make sure that the repositories sectio
material.io
이곳의 4번째 항목
Change your app theme to inherit from a Material Components theme
을 읽어보면 된다.
반응형