LoginSignup
0
0

More than 3 years have passed since last update.

[Android]Material Designを導入したときに初めにつまづいたこと

Posted at

AndroidにMaterial Designを導入したときに、何度もつまづいたので、メモ。

初めての導入

build.gradleに以下を記載します。

    implementation 'com.google.android.material:material:1.3.0-alpha03'

Gradle Syncした後にMaterial Buttonを使ってみます。

<com.google.android.material.button.MaterialButton
  style="@style/Widget.MaterialComponents.Button"
  ...
  />

実行、そしてクラッシュ

このボタンがあるActivityを起動すると、以下のエラーで落ちました。

Error inflating class com.google.android.material.button.MaterialButton

解決方法

res/values/styles.xml をMaterial Design用に変えないといけない。

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

    <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

参考

https://qiita.com/susu_susu__/items/67f86582188ff28ad910
https://material.io/develop/android/docs/getting-started

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0