Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Material Design Components カスタマイズ最前線
Yuki Anzai
October 17, 2020
Technology
7
4.1k
Material Design Components カスタマイズ最前線
Yuki Anzai
October 17, 2020
Tweet
Share
More Decks by Yuki Anzai
See All by Yuki Anzai
Material3 with Jetpack Compose
yanzm
2
2.1k
Jetpack Compose 1.2 新機能 / new features of Jetpack Compose 1.2
yanzm
0
280
Now in Android アプリ解説 / Now in Android App
yanzm
1
1.1k
キャッチアップ Android 13 / Catch up Android 13
yanzm
2
1.7k
(Android アプリ開発の)その書き方古いかも。/ Devfest Tokyo 2021
yanzm
3
2.6k
プロダクトレベルで必要になる Jetpack Compose テクニック
yanzm
9
6.4k
ML Kit's on-device APIs
yanzm
1
540
ML Kit 最新情報 (@ DevFest Tokyo 2019)
yanzm
4
3k
Jetpack Compose どうなの?(Android Dev Summit 2019報告会)
yanzm
7
3.1k
Other Decks in Technology
See All in Technology
Oracle Transaction Manager for Microservices Free 22.3 製品概要
oracle4engineer
PRO
5
110
スクラム導入して変わったチーム、組織のありかた
yumechi
0
190
PCL (Point Cloud Library)の基本となぜ点群処理か_2023年_第2版.pdf
cvmlexpertguide
0
170
SSMパラメーターストアでクロススタック参照の罠を回避する
shuyakinjo
0
6.5k
書籍を書きました。 そう、VS Codeで。
takumanakagame
4
4.4k
AWS re:Invent 2022で発表された新機能を試してみた ~Cloud OperationとSecurity~ / New Cloud Operation and Security Features Announced at AWS reInvent 2022
yuj1osm
1
210
CES_2023_FleetWise_demo.pdf
sparkgene
0
110
AI Services 概要 / AI Services overview
oracle4engineer
PRO
0
170
金属加工屋の営業マンがSTマイクロで・・・
usashirou
0
160
Stripe / Okta Customer Identity Cloud(旧Auth0) の採用に至った理由 〜モリサワの SaaS 戦略〜
tomuro
0
130
OVN-Kubernetes-Introduction-ja-2023-01-27.pdf
orimanabu
1
380
KyvernoとRed Hat ACMを用いたマルチクラスターの一元的なポリシー制御
ry
0
170
Featured
See All Featured
A better future with KSS
kneath
230
16k
The Web Native Designer (August 2011)
paulrobertlloyd
76
2.2k
Code Review Best Practice
trishagee
50
11k
The Straight Up "How To Draw Better" Workshop
denniskardys
226
130k
Faster Mobile Websites
deanohume
295
29k
Statistics for Hackers
jakevdp
785
210k
Agile that works and the tools we love
rasmusluckow
320
20k
How GitHub (no longer) Works
holman
298
140k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
236
1.1M
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
120
29k
The Art of Programming - Codeland 2020
erikaheidi
35
11k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
351
21k
Transcript
Material Design Components カスタマイズ最前線 あんざいゆき(@yanzm) Google Developer Experts for Android
Material Design Components • Material Design が提唱している⾊や形、タイポグラフィ、アニメーション を使ったコンポーネントが実装されているライブラリ • https://material.io/
• MDCに実装されているコンポーネントを使うには MDC のテーマを使う必要 がある implementation "com.google.android.material:material:1.2.1"
MDC のテーマを使う
MDC のテーマ Bridge Theme.MaterialComponents.Bridge Theme.MaterialComponents.Light.Bridge Theme.MaterialComponents.Light.DarkActionBar.Bridge Theme.MaterialComponents.DayNight non-Bridge Theme.MaterialComponents Theme.MaterialComponents.Light
Theme.MaterialComponents.Light.DarkActionBar Theme.MaterialComponents.DayNight コンポーネントに デフォルトで MDC の style が適⽤される デフォルトでは AppCompat と同じ⾒た⽬ non-Bridge と同じ⾒た⽬に するならコンポーネントに MDC の style を明⽰的に 適⽤する必要がある
MDC のテーマ • 新規プロジェクト • non-Bridge の MDC テーマをベーステーマにする •
既存プロジェクトの移⾏ • ベーステーマを non-Bridge の MDC テーマに変更すると影響が⼤きい ので、Bridge をベーステーマにして少しずつ設定を追加する • 最終的には Theme.MaterialComponents をベーステーマにする
Bridge をベーステーマにする <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> ... </style> <style name="Theme.MyApp.Light.DarkActionBar" parent="Theme.MaterialComponents.Light.DarkActionBar.Bridge">
... </style> AppCompat や MaterialComponents のネーミングルールに合わせて Theme.[MyApp].... という名前にするのがおすすめ
Bridge での設定 • MDC の style を設定しない → AppCompat と同じ
<com.google.android.material.textfield.TextInputLayout android:id="@+id/textInputLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_name"> ... </com.google.android.material.textfield.TextInputLayout>
Bridge での設定 • MDC の style を設定しない → AppCompat と同じ
• MDC の style を設定 → MaterialComponents と同じ <com.google.android.material.textfield.TextInputLayout android:id="@+id/textInputLayout" style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_name"> ... </com.google.android.material.textfield.TextInputLayout>
<style name="Theme.MyApp.Light.DarkActionBar" parent="..."> <item name="textInputStyle">@style/Widget.MaterialComponents.TextInputLayout.FilledBox</item> </style> Bridge での設定 • MDC
の style を設定しない → AppCompat と同じ • MDC の style を設定 → MaterialComponents と同じ
TextInputLayout AppCompat MaterialComponents .Bridge style 指定なし Widget.MaterialComponents .TextInputLayout .FilledBox エラー
MaterialComponents エラー Widget.MaterialComponents .TextInputLayout .OutlinedBox
MDC の Color 属性
colorAccent colorPrimaryDark colorPrimary AppCompat colorError android:colorBackground colorControlNormal
AppCompat colorError android:colorBackground テーマ継承による引き継ぎ colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface
colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorAccent colorPrimaryDark colorPrimary colorControlNormal MaterialComponents.Bridge colorControlNormal
colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface colorOnPrimarySurface colorSurface colorOnSurface colorError
colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary AppCompat MaterialComponents.Bridge MaterialComponents android:colorBackground colorError attr 参照 colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal テーマ継承による引き継ぎ
colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface colorOnPrimarySurface colorSurface colorOnSurface colorError
colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary AppCompat MaterialComponents.Bridge MaterialComponents android:colorBackground colorError attr 参照 colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal テーマ継承による引き継ぎ MDC で使われる Color
#303030 #FF7043 #FFFFFF #000000 android:colorBackground #121212 #FFFFFF #FFFFFF #121212 #121212
#000000 #000000 #03DAC6 #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary AppCompat MaterialComponents.Bridge MaterialComponents colorError attr 参照 colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal テーマ継承による引き継ぎ #212121 #000000 #FF7043 #FAFAFA #CF6679 #3700B3 #03DAC6 #000000 #212121 #FFFFFF #3700B3 #000000 #FFFFFF Dark theme #000000 #BA86FC #000000 #03DAC6 #03DAC6 #121212 #FFFFFF #121212
#303030 #FF7043 #FFFFFF #000000 android:colorBackground #121212 #FFFFFF #FFFFFF #121212 #121212
#000000 #000000 #03DAC6 #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary colorError attr 参照 colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal テーマ継承による引き継ぎ #212121 #000000 #FF7043 #FAFAFA #CF6679 #3700B3 #03DAC6 #000000 #212121 #FFFFFF #3700B3 #000000 #FFFFFF Dark theme #000000 #BA86FC #000000 #03DAC6 #03DAC6 #121212 #FFFFFF #121212 AppCompat MaterialComponents.Bridge MaterialComponents
#212121 #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface colorOnPrimarySurface
colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError attr 参照 colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal テーマ継承による引き継ぎ #f5f5f5 #757575 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF Light theme #f5f5f5 #6200EE #3700B3 AppCompat.Light MaterialComponents.Light.Bridge MaterialComponents.Light
#212121 #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface colorOnPrimarySurface
colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError attr 参照 colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal テーマ継承による引き継ぎ #f5f5f5 #757575 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF Light theme #f5f5f5 #6200EE #3700B3 AppCompat.Light MaterialComponents.Light.Bridge MaterialComponents.Light
#212121 #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface colorOnPrimarySurface
colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError attr 参照 colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal テーマ継承による引き継ぎ #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF Light theme #000000 #212121 AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc
#212121 #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface colorOnPrimarySurface
colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF Light theme #000000 #212121 attr 参照 テーマ継承による引き継ぎ AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc
Light theme #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface
colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF MDC で使われる Color #212121 #000000 #212121 attr 参照 テーマ継承による引き継ぎ AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc colorOnPrimary colorOnSecondary colorOnPrimarySurface colorOnSurface colorOnError colorOnBackground
• ColorXX 上の⽂字⾊やアイコンのTintに使われる colorPrimary colorSecondary colorPrimarySurface colorSurface colorError android:colorBackground #ffffff
#000000 #ffffff #000000 #ffffff #000000 ColorOnXX Android Android Android Android Android colorOnPrimary colorOnSecondary colorOnPrimarySurface colorOnSurface colorOnError colorOnBackground Android #212121 #03DAC6 #212121 #FFFFFF #FF5722 #FAFAFA MaterialComponents.Light.DarkActionBar.Bridge
Light theme #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface
colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF MDC で使われる Color #212121 #000000 #212121 attr 参照 テーマ継承による引き継ぎ AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc colorPrimarySurface colorOnPrimarySurface
PrimarySurface • Light theme では Primary、Dark theme では Surface を参照するよう
になっているColor属性 (Light Theme) Theme.MaterialComponents.Light Theme.MaterialComponents.Light .DarkActionBar (Dark Theme) Theme.MaterialComponents colorPrimarySurface ?attr/colorPrimary ?attr/colorSurface colorOnPrimarySurface ?attr/colorOnPrimary ?attr/colorOnSurface
Light theme #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface
colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF MDC で使われる Color #212121 #000000 #212121 attr 参照 テーマ継承による引き継ぎ AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc colorSurface colorOnSurface
• パネル的なコンポーネントの⾊に使われる • MaterialCardView, NavigationView, BottomNavigationView, BottomAppBar, TabLayout, PopupMenu, AlertDialog(MaterialAlertDialogBuilder)などの表⾯の⾊
colorSurface
Light theme #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface
colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF MDC で使われる Color #212121 #000000 #212121 attr 参照 テーマ継承による引き継ぎ AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc colorError colorOnError
colorError • エラー⽤の⽂字⾊やアイコンの Tint に使われる • TextInputLayout のエラー時の⽂字⾊やアイコンの⾊、 BottomNavigationView で使われる
BadgeDrawable の⾊
Light theme #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface
colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF MDC で使われる Color #212121 #000000 #212121 attr 参照 テーマ継承による引き継ぎ AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc android:colorBackground colorOnBackground
• window の背景に使われる • Theme.Material, Theme.Material.Light で android:windowBackground に指定されている android:colorBackground
<item name="windowBackground">?attr/colorBackground</item> android:colorBackground #FFFFFF Theme.MaterialComponents.Light.DarkActionBar Theme.MaterialComponents.Light.DarkActionBar.Bridge android:colorBackground #FAFAFA
Light theme #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface
colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF MDC で使われる Color #212121 #000000 #212121 attr 参照 テーマ継承による引き継ぎ AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc colorControlNormal
• AppCompat からある属性 • App bar の Navigation icon, Overflow
icon の Tint として使われる • MDC の ActionBar, BottomAppBar, Toolbar ⽤の style では上書き指定されている • App bar の Menu icon に指定する vector drawable は tint に colorControlNormal を指定する colorControlNormal <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:tint="?attr/colorControlNormal" android:viewportWidth="24" android:viewportHeight="24"> <path ... /> </vector>
MDC の Color 属性の利⽤
MDC ⽤ Color 属性の利⽤ colorPrimary : alpha 100% colorOnSurface :
alpha 42% colorError : alpha 100% TextInputLayout.FilledBox MaterialComponents.Light.DarkActionBar.Bridge colorOnSurface : alpha 12%
https://material.io/develop/android/components/text-fields
<style name="Widget.MaterialComponents.TextInputLayout.FilledBox" parent="Base.Widget.MaterialComponents.TextInputLayout"> ... <item name="boxBackgroundColor">@color/mtrl_filled_background_color</item> ... </style> <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="0.16" android:color="?attr/colorOnSurface" android:state_hovered="true"/> <item android:alpha="0.12" android:color="?attr/colorOnSurface" android:state_focused="true"/> <item android:alpha="0.04" android:color="?attr/colorOnSurface" android:state_enabled="false"/> <item android:alpha="0.12" android:color="?attr/colorOnSurface"/> </selector> mtrl_filled_background_color.xml
MDC の Color カスタマイズ
MDC の Color カスタマイズ • テーマの Color 属性値を変更する • 全
Component に影響する • materialThemeOverlay を指定する • Component ⽤の独⾃ style で指定する • 独⾃ style を指定した Component にだけ影響する <com.google.android.material.textfield.TextInputLayout ... app:colorPrimary="#1976D2"> <style name="Theme.MyApp.Light.DarkActionBar" ...> <item name="colorPrimary">#1976D2</item> </style>
materialThemeOverlay を指定する(1) • 独⾃ style のベースにしたい Component の style を調べる
materialThemeOverlay を指定する(2) • ベースにする style を継承した style を⽤意する <style name="Widget.MyApp.TextInputLayout.FilledBox"
parent="Widget.MaterialComponents.TextInputLayout.FilledBox"> </style>
materialThemeOverlay を指定する(3) • ベースにする style で materialThemeOverlay が指定されているか調べ る <style
name="Widget.MaterialComponents.TextInputLayout.FilledBox" parent="..."> <item name="materialThemeOverlay"> @style/ThemeOverlay.MaterialComponents.TextInputEditText.FilledBox </item> ... </style>
materialThemeOverlay を指定する(4) • ベースにする style で materialThemeOverlay に指定されている ThemeOverlay を継承したテーマを⽤意し、Color
属性を上書きする <style name="ThemeOverlay.MyApp.TextInputEditText.FilledBox" parent="ThemeOverlay.MaterialComponents.TextInputEditText.FilledBox"> <item name="colorPrimary">#1976D2</item> </style> materialThemeOverlay が指定されていないときは parent=""
materialThemeOverlay を指定する(4) • ベースにする style で materialThemeOverlay に指定されている ThemeOverlay を継承したテーマを⽤意し、Color
属性を上書きする <style name="ThemeOverlay.MyApp.TextInputEditText.FilledBox" parent="ThemeOverlay.MaterialComponents.TextInputEditText.FilledBox"> <item name="colorPrimary">#1976D2</item> </style> materialThemeOverlay が指定されていないときは parent=""
materialThemeOverlay を指定する(5) • Component ⽤の独⾃ style で、materialThemeOverlay に⽤意した ThemeOverlay を指定する
<style name="Widget.MyApp.TextInputLayout.FilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox"> <item name="materialThemeOverlay"> @style/ThemeOverlay.MyApp.TextInputEditText.FilledBox </item> </style>
materialThemeOverlay を指定する(6-1) • Component ⽤の独⾃ style を Component に指定する <com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout" style="@style/Widget.MyApp.TextInputLayout.FilledBox" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/hint_name">
materialThemeOverlay を指定する(6-2) • Component ⽤の独⾃ style を Component のデフォルト style
テーマ属 性に指定する <style name="Theme.MyApp.Light.DarkActionBar" parent="..."> <item name="textInputStyle">@style/Widget.MyApp.TextInputLayout.FilledBox</item> </style>
Bridge を使うときの注意点 - Button -
• Bridge と non-Bridge で異なる • 実際に⽣成される <Button> のインスタンス •
AppCompat : AppCompatButton • MaterialComponents.Bridge : AppCompatButton • MaterialComponents : MaterialButton • Bridge だと MDC の Button style を指定しても意図した通りにならない Button
Button AppCompat MaterialComponents .Bridge style 指定なし Widget.MaterialComponents .Button エラー MaterialComponents
エラー Widget.MaterialComponents .Button .OutlinedButton
Bridge + MaterialButton <com.google.android.material.button.MaterialButton android:id="@+id/button" style="@style/Widget.MaterialComponents.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/button" />
Bridge を使うときの注意点 - FloatingActionButton -
• MDC の style を指定する FloatingActionButton
FloatingActionButton AppCompat MaterialComponents .Bridge style 指定なし Widget.MaterialComponents.FloatingActionButton エラー MaterialComponents
Bridge を使うときの注意点 - CheckBox -
• Bridge と non-Bridge で異なる • 実際に⽣成される <CheckBox> のインスタンス •
AppCompat : AppCompatCheckBox • MaterialComponents.Bridge : AppCompatCheckBox • MaterialComponents : MaterialCheckBox • Bridge で MDC の CheckBox style を指定すると落ちる CheckBox
Bridge で MDC の style を適⽤する <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkBox" style="@style/Widget.MaterialComponents.CompoundButton.CheckBox" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/check_box" /> Crash! <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/check_box" app:useMaterialThemeColors="true" />
CheckBox AppCompat MaterialComponents .Bridge CheckBox MaterialCheckBox + useMaterialThemeColors="true" MaterialComponents エラー
MaterialCheckBox OK ?
CheckBox AppCompat MaterialComponents .Bridge CheckBox MaterialCheckBox + useMaterialThemeColors="true" MaterialComponents エラー
MaterialCheckBox OK colorControlActivated
#03DAC6 #008577 colorSecondary colorControlActivated colorAccent AppCompat MaterialComponents.Bridge MaterialComponents attr 参照
colorControlActivated colorAccent テーマ継承による引き継ぎ Light.DarkActionBar #03DAC6 #008577 #03DAC6 colorControlActivated colorAccent #008577 #008577
Bridge で MDC と同じ⾒た⽬にする <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox"> <item name="useMaterialThemeColors">true</item> <item
name="android:minWidth">@dimen/mtrl_min_touch_target_size</item> <item name="android:minHeight">@dimen/mtrl_min_touch_target_size</item> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> <style name="ThemeOverlay.MyApp.CompoundButton.CheckBox" parent=""> <item name="colorAccent">?attr/colorSecondary</item> </style> <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkbox" style="@style/Widget.MyApp.CompoundButton.CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/check_box" />
Bridge で MDC と同じ⾒た⽬にする <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox"> <item name="useMaterialThemeColors">true</item> <item
name="android:minWidth">@dimen/mtrl_min_touch_target_size</item> <item name="android:minHeight">@dimen/mtrl_min_touch_target_size</item> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> <style name="ThemeOverlay.MyApp.CompoundButton.CheckBox" parent=""> <item name="colorAccent">?attr/colorSecondary</item> </style> <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkbox" style="@style/Widget.MyApp.CompoundButton.CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/check_box" />
Bridge で MDC と同じ⾒た⽬にする <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox"> <item name="useMaterialThemeColors">true</item> <item
name="android:minWidth">@dimen/mtrl_min_touch_target_size</item> <item name="android:minHeight">@dimen/mtrl_min_touch_target_size</item> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> <style name="ThemeOverlay.MyApp.CompoundButton.CheckBox" parent=""> <item name="colorAccent">?attr/colorSecondary</item> </style> <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkbox" style="@style/Widget.MyApp.CompoundButton.CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/check_box" /> 48dp
Bridge を使うときの注意点 - RadioButton -
• Bridge と non-Bridge で異なる • 実際に⽣成される <RadioButton> のインスタンス •
AppCompat : AppCompatRadioButton • MaterialComponents.Bridge : AppCompatRadioButton • MaterialComponents : MaterialRadioButton • Bridge で MDC の RadioButton style を指定すると落ちる RadioButton
Bridge で MDC と同じ⾒た⽬にする <style name="Widget.MyApp.CompoundButton.RadioButton" parent="Widget.AppCompat.CompoundButton.RadioButton"> <item name="useMaterialThemeColors">true</item> <item
name="android:minWidth">@dimen/mtrl_min_touch_target_size</item> <item name="android:minHeight">@dimen/mtrl_min_touch_target_size</item> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.RadioButton</item> </style> <style name="ThemeOverlay.MyApp.CompoundButton.RadioButton" parent=""> <item name="colorAccent">?attr/colorSecondary</item> </style> <com.google.android.material.radiobutton.MaterialRadioButton android:id="@+id/radiobutton" style="@style/Widget.MyApp.CompoundButton.RadioButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/radio_button" />
Bridge を使うときの注意点 - Switch -
• SwitchMaterial を使う • Bridge で MDC の Switch style
を指定すると落ちる Switch (MaterialSwitch じゃないよ!)
Bridge で MDC と同じ⾒た⽬にする <style name="Widget.MyApp.CompoundButton.Switch" parent="Widget.AppCompat.CompoundButton.Switch"> <item name="useMaterialThemeColors">true</item> <item
name="android:minWidth">@dimen/mtrl_min_touch_target_size</item> <item name="android:minHeight">@dimen/mtrl_min_touch_target_size</item> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.Switch</item> </style> <style name="ThemeOverlay.MyApp.CompoundButton.Switch" parent=""> <item name="colorAccent">?attr/colorSecondary</item> </style> <com.google.android.material.switchmaterial.SwitchMaterial android:id="@+id/switch" style="@style/Widget.MyApp.CompoundButton.Switcdh" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/switch" />
Bridge を使うときの注意点 - TextInputLayout -
TextInputLayout AppCompat MaterialComponents .Bridge style 指定なし Widget.MaterialComponents .TextInputLayout .FilledBox エラー
MaterialComponents エラー Widget.MaterialComponents .TextInputLayout .OutlinedBox
Theme.MaterialComponents.Light.DarkActionBar Theme.MaterialComponents.Light.DarkActionBar.Bridge • Bridge と non-Bridge で error の⾊が異なる •
Bridge で error の⾊を non-Bridge と同じにするには • colorError を指定する or android:theme を指定する TextInputLayout
<style name="Theme.MyApp.Light.DarkActionBar" parent="...Bridge"> <item name="colorError">#B00020</item> </style> colorErrorを指定する <style name="Theme.MyApp.Light.DarkActionBar" parent="...Bridge">
<item name="colorError">@color/design_default_color_error</item> </style> or #CF6679 #B00020 Light テーマ : @color/design_default_color_error Dark テーマ : @color/design_dark_default_color_error
• ThemeOverlay.MaterialComponents.[Light|Dark] を指定する android:theme を指定する <com.google.android.material.textfield.TextInputLayout android:id="@+id/textInputLayout" style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox" ... android:theme="@style/ThemeOverlay.MaterialComponents.Light">
... </com.google.android.material.textfield.TextInputLayout>
ThemeOverlay.MaterialComponents • color 関係の属性だけ指定されているテーマ ThemeOverlay.MaterialComponents ThemeOverlay.MaterialComponents.Light ThemeOverlay.MaterialComponents.Dark
<style name="ThemeOverlay.MaterialComponents.Light" parent="ThemeOverlay.AppCompat.Light"> <item name="android:colorBackground">@color/design_default_color_background</item> <item name="colorOnBackground">@color/design_default_color_on_background</item> <item name="colorSurface">@color/design_default_color_surface</item> <item
name="colorOnSurface">@color/design_default_color_on_surface</item> <item name="colorError">@color/design_default_color_error</item> <item name="colorOnError">@color/design_default_color_on_error</item> </style> #FFFFFF #000000 #FFFFFF #000000 #B00020 #FFFFFF ThemeOverlay.MaterialComponents.Light ThemeOverlay.MaterialComponents.Dark #121212 <style name="ThemeOverlay.MaterialComponents.Dark" parent="ThemeOverlay.AppCompat.Dark"> <item name="android:colorBackground">@color/design_dark_default_color_background</item> <item name="colorOnBackground">@color/design_dark_default_color_on_background</item> <item name="colorSurface">@color/design_dark_default_color_surface</item> <item name="colorOnSurface">@color/design_dark_default_color_on_surface</item> <item name="colorError">@color/design_dark_default_color_error</item> <item name="colorOnError">@color/design_dark_default_color_on_error</item> </style> #FFFFFF #000000 #CF6679 #121212 #FFFFFF
Light theme #03DAC6 #008577 colorPrimaryVariant colorOnPrimary colorSecondary colorSecondaryVariant colorOnSecondary colorPrimarySurface
colorOnPrimarySurface colorSurface colorOnSurface colorError colorOnError android:colorBackground colorOnBackground colorPrimary colorControlNormal colorAccent colorPrimaryDark colorPrimary android:colorBackground colorError colorError android:colorBackground colorAccent colorPrimaryDark colorPrimary colorControlNormal #212121 #000000 #FF5722 #FAFAFA #B00020 #FFFFFF #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #000000 #FFFFFF #212121 #FAFAFA #FF5722 #FFFFFF #212121 #3700B3 #03DAC6 #018786 #FFFFFF #FFFFFF #000000 #000000 #FFFFFF #000000 #FFFFFF MDC で使われる Color #212121 #000000 #212121 attr 参照 テーマ継承による引き継ぎ AppCompat.Light.DarkActionBar MaterialComponents.Light.DarkActionBar.Bridge MaterialComponents.Light.DarkAc ThemeOverlay に指定
Bridge を使うときの注意点 - Tab -
Tab AppCompat MaterialComponents .Bridge style 指定なし Widget.MaterialComponents .TabLayout エラー MaterialComponents
エラー Widget.MaterialComponents .TabLayout .Colored
Bridge を使うときの注意点 - Bottom Navigation -
BottomNavigationView AppCompat MaterialComponents .Bridge style 指定なし Widget.MaterialComponents .BottomNavigationView エラー MaterialComponents
エラー Widget.MaterialComponents .BottomNavigationView .Colored
Bridge を使うときの注意点 - CardView -
• MaterialCardView を使う • MDC の style を指定する CardView
MaterialCardView AppCompat MaterialComponents .Bridge style 指定なし Widget.MaterialComponents.CardView エラー MaterialComponents エラー
<item name="colorPrimary">#1976D2</item> <item name="colorSurface">#E3F2FD</item> ?attr/borderlessButtonStyle
Bridge を使うときの注意点 - AppBarLayout, Toolbar -
• MaterialToolbar を使う • AppBarLayout と⼀緒に使う時は MDC の style を指定する
Toolbar
MaterialToolbar MaterialComponents .Bridge style 指定なし Widget.MaterialComponents .Toolbar MaterialComponents Widget.MaterialComponents .Toolbar.Primary
AppBarLayout + MaterialToolbar MaterialComponents .Bridge style 指定なし or Widget.MaterialComponents .Toolbar
Widget.MaterialComponents .Toolbar.Surface MaterialComponents Widget.MaterialComponents .Toolbar.Primary
Bridge を使うときの注意点 - BottomAppBar -
BottomAppBar MaterialComponents .Bridge style 指定なし Widget.MaterialComponents .BottomAppBar MaterialComponents Widget.MaterialComponents .BottomAppBar
.Colored
Dark mode
Dark mode • night mode : API Level 8 〜
• Dark mode 向けの設定は [values]-night-v8 に指定 • 設定 → ディスプレイ → ダークテーマ • バッテリセーバーモード
parent Theme.MaterialComponents Theme.MaterialComponents .Light.DarkActionBar Theme.MaterialComponents .DayNight .DarkActionBar .Bridge Theme.MaterialComponents .Bridge
Theme.MaterialComponents .Light.DarkActionBar .Bridge colorPrimary #212121 colorPrimary #212121 colorPrimary #BA86FC Bridge colorPrimary #212121 Theme.MaterialComponents .DayNight .DarkActionBar non-Bridge normal Dark mode DayNight
Theme.MaterialComponents .DayNight .DarkActionBar normal Dark mode Theme.MaterialComponents .DayNight .DarkActionBar .Bridge
#BA86FC non-Bridge Bridge colorPrimary #212121 colorPrimary #212121 colorPrimary #212121 colorPrimary DayNight
Selected Tab の⾊を変える <style name="Widget.MyApp.TabLayout" parent="Widget.MaterialComponents.TabLayout"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TabLayout</item> </style> <style
name="ThemeOverlay.MyApp.TabLayout" parent=""> <item name="colorPrimary">#1976D2</item> </style>
Theme.MaterialComponents .DayNight .DarkActionBar normal Dark mode Theme.MaterialComponents .DayNight .DarkActionBar .Bridge
non-Bridge Bridge DayNight
Dark mode の Selected Tab の⾊を変える <style name="Widget.MyApp.TabLayout" parent="Widget.MaterialComponents.TabLayout"> <item
name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TabLayout</item> </style> <style name="ThemeOverlay.MyApp.TabLayout" parent="" /> res/values-night-v8/themes.xml <style name="ThemeOverlay.MyApp.TabLayout" parent=""> <item name="colorPrimary">#1976D2</item> </style> res/values/themes.xml
Theme.MaterialComponents .DayNight .DarkActionBar normal Dark mode Theme.MaterialComponents .DayNight .DarkActionBar .Bridge
non-Bridge Bridge DayNight
normal Dark mode Primary Surface .TabLayout.PrimarySurface .ActionBar.PrimarySurface .AppBarLayout.PrimarySurface .BottomAppBar.PrimarySurface .BottomNavigationView.PrimarySurface
.Toolbar.PrimarySurface Widget.MaterialComponents .Toolbar.Primary .Toolbar.Surface .TabLayout .BottomNavigationView .BottomAppBar .AppBarLayout.Surface .ActionBar.Surface .TabLayout.Colored .BottomNavigationView.Colored .BottomAppBar.Colored .BottomAppBar.Primary .ActionBar.Primary
normal Dark mode non-Bridge Bridge TabLayout .PrimarySurface
Android Studio 4.1
Android Studio 4.1 • 新規プロジェクトを作成したときのアプリのベーステーマが Theme.MaterialComponents.DayNight.DarkActionBar になった • テーマの定義先が styles.xml
から themes.xml に変わった • ⽣成されるアプリのテーマ名が Theme.[アプリ名] に変わった
res/values-night-v8/themes.xml res/values/themes.xml <style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item> <item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorOnPrimary">@color/white</item> <!-- Secondary brand color. --> <item name="colorSecondary">@color/teal_200</item> <item name="colorSecondaryVariant">@color/teal_700</item> <item name="colorOnSecondary">@color/black</item> <!-- Status bar color. --> <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> <!-- Customize your theme here. --> </style> <style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> <!-- Primary brand color. --> <item name="colorPrimary">@color/purple_200</item> <item name="colorPrimaryVariant">@color/purple_700</item> <item name="colorOnPrimary">@color/black</item> <!-- Secondary brand color. --> <item name="colorSecondary">@color/teal_200</item> <item name="colorSecondaryVariant">@color/teal_200</item> <item name="colorOnSecondary">@color/black</item> <!-- Status bar color. --> <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item> <!-- Customize your theme here. --> </style> #6200EE #3700B3 #FFFFFF #03DAC5 #018786 #000000 #3700B3 #3700B3 #000000 #03DAC5 #03DAC5 #000000 #BB86FC #3700B3
#6200EE #6200EE #6200EE normal Dark mode #03DAC5 #03DAC5 #BB86FC #3700B3
#03DAC5 #03DAC5 #BB86FC #BB86FC #03DAC5 #03DAC5 #3700B3 #03DAC5 #03DAC5 #6200EE #BB86FC
まとめ • 新しいプロジェクトを作るときは no-Bridge をベースにする • 既存のプロジェクトを移⾏するときは Bridge をベースにして徐々に適⽤を広げる •
Bridge テーマには落とし⽳があるので注意する • MaterialButton, MaterialCheckBox, MaterialRadioButton, SwitchMaterial を使う • ⾊をカスタマイズするときは materialThemeOverlay を指定する • Dark Mode 対応がんばろう
カスタマイズ レシピ集
Button
Button の style colorPrimary : alpha 100% colorOnPrimary : alpha
100% #FFFFFF #212121 Widget.MaterialComponents.Button Widget.MaterialComponents.Button.UnelevatedButton Widget.MaterialComponents.Button.OutlinedButton Widget.MaterialComponents.Button.TextButton colorOnSurface : alpha 12% #000000
Button の⾊を変える <style name="ThemeOverlay.MyApp.Button.Blue" parent=""> <item name="colorPrimary">#1976D2</item> </style> <com.google.android.material.button.MaterialButton android:id="@+id/button"
style="@style/Widget.MyApp.Button" ... /> <style name="Widget.MyApp.Button" parent="Widget.MaterialComponents.Button"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.Button.Blue</item> </style> <style name="Theme.MyApp.Light.DarkActionBar" parent="..."> <item name="materialButtonStyle">@style/Widget.MyApp.Button</item> </style> or
Button.Icon app:iconGravity="start" Widget.MaterialComponents .Button.Icon app:iconGravity="end" app:iconGravity="textStart" app:iconGravity="textEnd" Widget.MaterialComponents .Button.OutlinedButton.Icon
Icon に Tint しない app:iconTint="@null" app:iconTint="#ff9573"
Button の形を変える • shapeAppearance を指定する <style name="Widget.MyApp.Button" parent="Widget.MaterialComponents.Button"> <item name="shapeAppearance">@style/ShapeAppearance.MyApp.Button</item>
</style> <style name="ShapeAppearance.MyApp.Button" parent=""> <item name="cornerFamily">cut</item> <item name="cornerSize">8dp</item> </style> <style name="ShapeAppearance.MyApp.Button" parent=""> <item name="cornerFamily">rounded</item> <item name="cornerSize">20dp</item> </style>
FloatingActionButton
#000000 #03DAC6 FloatingActionButton の style colorOnSecondary : alpha 100% colorSecondary
: alpha 12% Widget.MaterialComponents.FloatingActionButton
#000000 #03DAC6 ExtendedFloatingActionButton の style colorOnSecondary : alpha 100% colorSecondary
: alpha 12% Widget.MaterialComponents.ExtendedFloatingActionButton Widget.MaterialComponents.ExtendedFloatingActionButton.Icon
<style name="Widget.MyApp.FloatingActionButton" parent="Widget.MaterialComponents.FloatingActionButton"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.FloatingActionButton</item> </style> FloatingActionButton の⾊を変える <com.google.android.material.floatingactionbutton.FloatingActionButton ...
style="@style/Widget.MyApp.FloatingActionButton" ... /> <style name="ThemeOverlay.MyApp.FloatingActionButton" parent=""> <item name="colorSecondary">#1976D2</item> <item name="colorOnSecondary">#FFFFFF</item> </style>
CheckBox
CheckBox の style layer(colorSurface, colorOnSurface) : alpha 54% android:textColorPrimary #de000000
layer(colorSurface, colorControlActivated) : alpha 100% layer(colorSurface, colorOnSurface) : alpha 38% #39000000 enabled disabled #000000 #03DAC6 #000000 (alpha 22%) (alpha 87%)
CheckBox の⾊を変える(1) <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox"> ... <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> <style
name="ThemeOverlay.MyApp.CompoundButton.CheckBox" parent=""> <item name="colorAccent">?attr/colorSecondary</item> <item name="colorSecondary">#1976D2</item> </style> Bridge non-Bridge <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.MaterialComponents.CompoundButton.CheckBox"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style>
CheckBox の⾊を変える(1) <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox"> ... <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> <style
name="ThemeOverlay.MyApp.CompoundButton.CheckBox" parent=""> <item name="colorAccent">?attr/colorSecondary</item> <item name="colorSecondary">#1976D2</item> </style> Bridge non-Bridge <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.MaterialComponents.CompoundButton.CheckBox"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> 全部⻘にしたい
CheckBox の⾊を変える(2) <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox"> ... <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> <style
name="ThemeOverlay.MyApp.CompoundButton.CheckBox" parent=""> <item name="colorAccent">?attr/colorSecondary</item> <item name="colorSecondary">#1976D2</item> <item name="colorOnSurface">#1976D2</item> </style> Bridge non-Bridge <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.MaterialComponents.CompoundButton.CheckBox"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style>
CheckBox の⾊を変える(2) <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.AppCompat.CompoundButton.CheckBox"> ... <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> <style
name="ThemeOverlay.MyApp.CompoundButton.CheckBox" parent=""> <item name="colorAccent">?attr/colorSecondary</item> <item name="colorSecondary">#1976D2</item> <item name="colorOnSurface">#1976D2</item> </style> Bridge non-Bridge <style name="Widget.MyApp.CompoundButton.CheckBox" parent="Widget.MaterialComponents.CompoundButton.CheckBox"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style> もっと薄くしたい 薄くしたくない
CheckBox の⾊を変える(3) <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="0.20" android:color="#1976D2"
android:state_checked="true" android:state_enabled="false" /> <item android:alpha="0.20" android:color="#1976D2" android:state_enabled="false" /> <item android:alpha="1.00" android:color="#1976D2" android:state_checked="true" /> <item android:alpha="1.00" android:color="#1976D2" /> </selector> <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkbox" style="@style/Widget.MyApp.CompoundButton.CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:buttonTint="@color/check_box_tint" android:text="@string/check_box" /> res/color/check_box_tint.xml
CheckBox の⾊を変える(3) <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="0.20" android:color="#1976D2"
android:state_checked="true" android:state_enabled="false" /> <item android:alpha="0.20" android:color="#1976D2" android:state_enabled="false" /> <item android:alpha="1.00" android:color="#1976D2" android:state_checked="true" /> <item android:alpha="1.00" android:color="#1976D2" /> </selector> <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkbox" style="@style/Widget.MyApp.CompoundButton.CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:buttonTint="@color/check_box_tint" android:text="@string/check_box" /> res/color/check_box_tint.xml ripple も⻘にしたい
CheckBox の⾊を変える(4) <style name="ThemeOverlay.MyApp.CompoundButton.CheckBox" parent=""> <item name="colorAccent">?attr/colorSecondary</item> <item name="colorSecondary">#1976D2</item> <item
name="colorOnSurface">#1976D2</item> <item name="colorControlHighlight">#1a1976D2</item> </style> <style name="Widget.MyApp.CompoundButton.CheckBox" parent="..."> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.CheckBox</item> </style>
CheckBox の⾊を変える(5) <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/check_box_ripple_color" android:radius="20dp" /> <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkbox" style="@style/Widget.MyApp.CompoundButton.CheckBox"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/check_box_background" android:buttonTint="@color/check_box_tint" android:text="@string/check_box" /> res/drawable/check_box_background.xml <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="0.10" android:color="#1976D2" /> </selector> res/color/check_box_ripple_color.xml
独⾃画像の CheckBox にする • app:useMaterialThemeColors="false" を指定する • → MDC Color
によって Tint されない <com.google.android.material.checkbox.MaterialCheckBox android:id="@+id/checkbox1" style="@style/Widget.MyApp.CompoundButton.CheckBox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@drawable/check_box_custom" android:text="@string/check_box" app:useMaterialThemeColors="false" />
RadioButton
RadioButton の style layer(colorSurface, colorOnSurface) : alpha 54% android:textColorPrimary #de000000
layer(colorSurface, colorControlActivated) : alpha 100% layer(colorSurface, colorOnSurface) : alpha 38% #39000000 enabled disabled #000000 #03DAC6 #000000 (alpha 22%) (alpha 87%)
Switch
Switch の style android:textColorPrimary #de000000 layer(colorSurface, colorControlActivated) : alpha 100%
#39000000 enabled disabled (alpha 22%) (alpha 87%) layer(colorSurface, colorControlActivated) : alpha 38% #03DAC6 layer(colorSurface, colorControlActivated) : alpha 12% layer(colorSurface, colorOnSurface) : alpha 12% layer(colorSurface, colorOnSurface) : alpha 32% colorSurface thumb colorSurface #03DAC6 track #FFFFFF layer(colorSurface, colorControlActivated) : alpha 54% #000000 #03DAC6 #000000 #03DAC6 #FFFFFF
Switch の⾊を変える(1) <style name="Widget.MyApp.CompoundButton.Switch" parent="Widget.AppCompat.CompoundButton.Switch"> ... <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.Switch</item> </style> <style
name="ThemeOverlay.MyApp.CompoundButton.Switch" parent=""> <item name="colorAccent">?attr/colorSecondary</item> <item name="colorSecondary">#1976D2</item> </style> Bridge non-Bridge <style name="Widget.MyApp.CompoundButton.Switch" parent="Widget.MaterialComponents.CompoundButton.Switch"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.Switch</item> </style>
Switch の⾊を変える(1) <style name="Widget.MyApp.CompoundButton.Switch" parent="Widget.AppCompat.CompoundButton.Switch"> ... <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.Switch</item> </style> <style
name="ThemeOverlay.MyApp.CompoundButton.Switch" parent=""> <item name="colorAccent">?attr/colorSecondary</item> <item name="colorSecondary">#1976D2</item> </style> Bridge non-Bridge <style name="Widget.MyApp.CompoundButton.Switch" parent="Widget.MaterialComponents.CompoundButton.Switch"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CompoundButton.Switch</item> </style> track をもう少し薄くしたい
Switch の⾊を変える(2) <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="0.12" android:color="?attr/colorControlActivated"
android:state_checked="true" android:state_enabled="false" /> <item android:alpha="0.12" android:color="?attr/colorOnSurface" android:state_enabled="false" /> <item android:alpha="0.54" android:color="?attr/colorControlActivated" android:state_checked="true" /> <item android:alpha="0.20" android:color="?attr/colorOnSurface" /> </selector> <com.google.android.material.switchmaterial.SwitchMaterial style="@style/Widget.MyApp.CompoundButton.Switch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/switch1" app:trackTint="@color/switch_track_tint" /> res/color/switch_track_tint.xml
Slider
#FFFFFF Slider の style colorPrimary : alpha 100% #212121 colorPrimary
: alpha 24% #212121 colorPrimary : alpha 54% #212121 colorOnPrimary : alpha 100% #FFFFFF colorOnPrimary : alpha 54% layer( android:colorBackground : alpha 90%, colorOnBackground : alpha 60% ) #000000
<style name="Widget.MyApp.Slider" parent="Widget.MaterialComponents.Slider"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.Slider</item> </style> Slider の⾊を変える <com.google.android.material.slider.Slider ...
style="@style/Widget.MyApp.Slider" ... /> <style name="ThemeOverlay.MyApp.Slider" parent=""> <item name="colorPrimary">#1976D2</item> <item name="colorOnBackground">#1976D2</item> </style>
TextInputLayout
TextInputLayout.FilledBox の style colorPrimary : alpha 100% colorOnSurface : alpha
42% colorError : alpha 100% colorOnSurface : alpha 12% colorOnSurface : alpha 54% colorOnSurface : alpha 60% #000000 #212121 android:textColorPrimary #de000000 #39000000 enabled disabled (alpha 22%) (alpha 87%) #B00020 #000000 colorOnSurface : alpha 54% colorError : alpha 100% colorOnSurface : alpha 60% colorOnSurface : alpha 60% #000000 #000000 #B00020 colorOnSurface : alpha 60% #000000 #000000 #000000 #000000 colorError : alpha 100% #B00020 colorPrimary : alpha 100% #212121 colorError : alpha 100% #B00020
TextInputLayout.OutlinedBox の style colorPrimary : alpha 100% colorOnSurface : alpha
38% colorError : alpha 100% colorOnSurface : alpha 60% colorOnSurface : alpha 60% #000000 #212121 android:textColorPrimary #de000000 #39000000 enabled disabled (alpha 22%) (alpha 87%) #B00020 colorOnSurface : alpha 60% colorError : alpha 100% colorOnSurface : alpha 60% colorOnSurface : alpha 60% #000000 #000000 #B00020 colorOnSurface : alpha 60% #000000 #000000 #000000 #000000 colorError : alpha 100% #B00020 colorPrimary : alpha 100% #212121 colorError : alpha 100% #B00020
TextInputLayout の⾊を変える(1) <style name="Widget.MyApp.TextInputLayout.FilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox"> ... <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TextInputEditText.FilledBox</item> </style> <style
name="ThemeOverlay.MyApp.TextInputEditText.FilledBox" parent="ThemeOverlay.MaterialComponents.TextInputEditText.FilledBox"> <item name="colorPrimary">#1976D2</item> </style>
TextInputLayout の⾊を変える(1) <style name="Widget.MyApp.TextInputLayout.FilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox"> ... <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TextInputEditText.FilledBox</item> </style> <style
name="ThemeOverlay.MyApp.TextInputEditText.FilledBox" parent="ThemeOverlay.MaterialComponents.TextInputEditText.FilledBox"> <item name="colorPrimary">#1976D2</item> </style> Box をもう少し薄くしたい
TextInputLayout の⾊を変える(2) <style name="Widget.MyApp.TextInputLayout.FilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TextInputEditText.FilledBox</item> <item name="boxBackgroundColor">@color/text_input_layout_box_background</item> </style>
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="0.12" android:color="?attr/colorOnSurface" android:state_hovered="true"/> <item android:alpha="0.06" android:color="?attr/colorOnSurface" android:state_focused="true"/> <item android:alpha="0.04" android:color="?attr/colorOnSurface" android:state_enabled="false"/> <item android:alpha="0.06" android:color="?attr/colorOnSurface"/> </selector> res/color/text_input_layout_box_background.xml
Tab
#FFFFFF #FFFFFF Tab の style colorPrimary : alpha 100% colorOnSurface
: alpha 60% colorSurface : alpha 100% #212121 #000000 #212121 #FFFFFF #FFFFFF colorPrimary : alpha 100% #212121 colorOnPrimary : alpha 100% colorOnPrimary : alpha 60% colorPrimary : alpha 100% colorOnPrimary : alpha 100% Widget.MaterialComponents.TabLayout.Colored Widget.MaterialComponents.TabLayout
Tab の⾊を変える(1) <style name="Widget.MyApp.TabLayout" parent="Widget.MaterialComponents.TabLayout"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TabLayout</item> </style> <style name="ThemeOverlay.MyApp.TabLayout"
parent=""> <item name="colorPrimary">#1976D2</item> </style> <com.google.android.material.tabs.TabLayout style="@style/Widget.MyApp.TabLayout" android:layout_width="match_parent" android:layout_height="wrap_content">
Tab の⾊を変える(1) <style name="Widget.MyApp.TabLayout" parent="Widget.MaterialComponents.TabLayout"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TabLayout</item> </style> <style name="ThemeOverlay.MyApp.TabLayout"
parent=""> <item name="colorPrimary">#1976D2</item> </style> 薄い⻘にしたい <com.google.android.material.tabs.TabLayout style="@style/Widget.MyApp.TabLayout" android:layout_width="match_parent" android:layout_height="wrap_content">
Tab の⾊を変える(2) <style name="Widget.MyApp.TabLayout" parent="Widget.MaterialComponents.TabLayout"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TabLayout</item> <item name="tabTextColor">@color/tab_text</item> </style>
res/color/tab_text.xml <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="1.00" android:color="?attr/colorPrimary" android:state_selected="true" /> <item android:alpha="0.40" android:color="?attr/colorPrimary" /> </selector>
Tab の⾊を変える(2) <style name="Widget.MyApp.TabLayout" parent="Widget.MaterialComponents.TabLayout"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TabLayout</item> <item name="tabTextColor">@color/tab_text</item> </style>
res/color/tab_text.xml unselected の ripple も⻘にしたい <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="1.00" android:color="?attr/colorPrimary" android:state_selected="true" /> <item android:alpha="0.40" android:color="?attr/colorPrimary" /> </selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="0.08" android:color="?attr/colorPrimary" android:state_pressed="true" /> <item android:alpha="0.16" android:color="?attr/colorPrimary"
android:state_focused="true" android:state_hovered="true" /> <item android:alpha="0.12" android:color="?attr/colorPrimary" android:state_focused="true" /> <item android:alpha="0.04" android:color="?attr/colorPrimary" android:state_hovered="true" /> <item android:alpha="0.00" android:color="?attr/colorPrimary" /> </selector> Tab の⾊を変える(3) <style name="Widget.MyApp.TabLayout" parent="Widget.MaterialComponents.TabLayout"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.TabLayout</item> <item name="tabTextColor">@color/tab_text</item> <item name="tabRippleColor">@color/tab_ripple</item> </style> res/color/tab_ripple.xml
Bottom Navigation
#FFFFFF BottomNavigationView の style colorPrimary : alpha 100% colorOnSurface :
alpha 60% colorSurface : alpha 100% #212121 #000000 #212121 #FFFFFF #FFFFFF colorOnPrimary : alpha 100% colorOnPrimary : alpha 60% colorPrimary : alpha 100% Widget.MaterialComponents.BottomNavigationView.Colored Widget.MaterialComponents.BottomNavigationView
<com.google.android.material.bottomnavigation.BottomNavigationView style="@style/Widget.MyApp.BottomNavigationView" android:layout_width="match_parent" android:layout_height="wrap_content"> BottomNavigationView の⾊を変える(1) <style name="Widget.MyApp.BottomNavigationView" parent="Widget.MaterialComponents.BottomNavigationView"> <item
name="materialThemeOverlay">@style/ThemeOverlay.MyApp.BottomNavigationView</item> </style> <style name="ThemeOverlay.MyApp.BottomNavigationView" parent=""> <item name="colorPrimary">#1976D2</item> </style>
<com.google.android.material.bottomnavigation.BottomNavigationView style="@style/Widget.MyApp.BottomNavigationView" android:layout_width="match_parent" android:layout_height="wrap_content"> BottomNavigationView の⾊を変える(1) <style name="Widget.MyApp.BottomNavigationView" parent="Widget.MaterialComponents.BottomNavigationView"> <item
name="materialThemeOverlay">@style/ThemeOverlay.MyApp.BottomNavigationView</item> </style> <style name="ThemeOverlay.MyApp.BottomNavigationView" parent=""> <item name="colorPrimary">#1976D2</item> </style> 薄い⻘にしたい
<com.google.android.material.bottomnavigation.BottomNavigationView style="@style/Widget.MyApp.BottomNavigationView" android:layout_width="match_parent" android:layout_height="wrap_content"> BottomNavigationView の⾊を変える(2) <style name="Widget.MyApp.BottomNavigationView" parent="Widget.MaterialComponents.BottomNavigationView"> <item
name="materialThemeOverlay">@style/ThemeOverlay.MyApp.BottomNavigationView</item> </style> <style name="ThemeOverlay.MyApp.BottomNavigationView" parent=""> <item name="colorPrimary">#1976D2</item> <item name="colorOnSurface">#1976D2</item> </style>
<com.google.android.material.bottomnavigation.BottomNavigationView style="@style/Widget.MyApp.BottomNavigationView" android:layout_width="match_parent" android:layout_height="wrap_content"> BottomNavigationView の⾊を変える(2) <style name="Widget.MyApp.BottomNavigationView" parent="Widget.MaterialComponents.BottomNavigationView"> <item
name="materialThemeOverlay">@style/ThemeOverlay.MyApp.BottomNavigationView</item> </style> <style name="ThemeOverlay.MyApp.BottomNavigationView" parent=""> <item name="colorPrimary">#1976D2</item> <item name="colorOnSurface">#1976D2</item> </style> もっと薄くしたい
<style name="Widget.MyApp.BottomNavigationView" parent="Widget.MaterialComponents.BottomNavigationView"> <item name="materialThemeOverlay">@style/ThemeOverlay.MyApp.BottomNavigationView</item> <item name="itemIconTint">@color/bottom_nav_item</item> <item name="itemTextColor">@color/bottom_nav_item</item> </style>
<style name="ThemeOverlay.MyApp.BottomNavigationView" parent=""> <item name="colorPrimary">#1976D2</item> <item name="colorOnSurface">#1976D2</item> </style> BottomNavigationView の⾊を変える(3) <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:alpha="1.0" android:color="?attr/colorPrimary" android:state_checked="true"/> <item android:alpha="0.3" android:color="?attr/colorOnSurface"/> </selector> res/color/bottom_nav_item.xml
CardView
#FFFFFF MaterialCardView の style colorSurface : alpha 100% #212121 #FFFFFF
colorPrimary : alpha 100% colorPrimary : alpha 8% Widget.MaterialComponents.CardView isChecked = true
<com.google.android.material.card.MaterialCardView style="@style/Widget.MyApp.CardView" android:layout_width="match_parent" android:layout_height="wrap_content"> MaterialCardView の⾊を変える(1) <style name="Widget.MyApp.CardView" parent="Widget.MaterialComponents.CardView"> <item
name="materialThemeOverlay">@style/ThemeOverlay.MyApp.CardView</item> </style> <style name="ThemeOverlay.MyApp.CardView" parent=""> <item name="colorPrimary">#1976D2</item> <item name="borderlessButtonStyle">@style/Widget.MaterialComponents.Button.TextButton</item> </style>
AppBarLayout, Toolbar
#FFFFFF #FFFFFF #FFFFFF #212121 Toolbar の style colorControlNormal → colorOnSurface
: alpha 60% null (background) Widget.MaterialComponents.Toolbar android:textColorPrimary #de000000 #39000000 enabled disabled (alpha 22%) (alpha 87%) colorControlNormal → android:textColorSecondary #8a000000 #24000000 enabled disabled (alpha 14%) (alpha 54%) Widget.MaterialComponents.Toolbar .Primary Widget.MaterialComponents.Toolbar .Surface colorSurface : alpha 100% #FFFFFF colorPrimary : alpha 100% colorOnSurface : alpha 87% #000000 colorOnSurface : alpha 60% #000000 #000000 colorOnPrimary : alpha 100% colorOnPrimary : alpha 60% colorControlNormal → colorOnPrimary : alpha 100%
#212121 AppBarLayout の style Widget.MaterialComponents.AppBarLayout.Surface Widget.MaterialComponents.AppBarLayout.Primary colorSurface : alpha 100%
#FFFFFF colorPrimary : alpha 100% android:textColorPrimary #de000000 #39000000 enabled disabled (alpha 22%) (alpha 87%)
AppBarLayout 内の⾊を変える(1) <com.google.android.material.appbar.AppBarLayout style="@style/Widget.MaterialComponents.AppBarLayout.Primary" android:layout_width="match_parent" android:layout_height="128dp"> <com.google.android.material.appbar.CollapsingToolbarLayout android:layout_width="match_parent" android:layout_height="match_parent" app:expandedTitleTextAppearance="@style/TextAppearance.MyApp.CollapsingToolbar.Expanded">
<com.google.android.material.appbar.MaterialToolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:theme="@style/ThemeOverlay.MaterialComponents.Toolbar.Primary" /> </com.google.android.material.appbar.CollapsingToolbarLayout> </com.google.android.material.appbar.AppBarLayout>
BottomAppBar
#FFFFFF #212121 BottomAppBar の style Widget.MaterialComponents.BottomAppBar colorControlNormal → android:textColorSecondary #8a000000
#24000000 enabled disabled (alpha 14%) (alpha 54%) Widget.MaterialComponents.BottomAppBar.Colored colorSurface : alpha 100% #FFFFFF colorPrimary : alpha 100% colorControlNormal → colorOnPrimary : alpha 100%
<com.google.android.material.bottomappbar.BottomAppBar style="@style/Widget.MyApp.BottomAppBar" android:layout_width="match_parent" android:layout_height="wrap_content"> BottomAppBar の⾊を変える(1) <style name="Widget.MyApp.BottomAppBar" parent="Widget.MaterialComponents.BottomAppBar"> <item
name="materialThemeOverlay">@style/ThemeOverlay.MyApp.BottomAppBar</item> </style> <style name="ThemeOverlay.MyApp.BottomAppBar" parent=""> <item name="colorControlNormal">#1976D2</item> </style>
ActionBar
MaterialComponents .Bridge MaterialComponents Widget.MaterialComponents MaterialComponents .Light.Bridge MaterialComponents .Light MaterialComponents .Light.DarkActionBar
.Bridge MaterialComponents .Light.DarkActionBar .Light.ActionBar.Solid .ActionBar.Surface .ActionBar.Solid .ActionBar.Primary actionBarStyle value primaryColor #212121 primarySurface #121212 primaryColor #BA86FC primarySurface #121212 primaryColor #f5f5f5 primarySurface #FFFFFF primaryColor #6200EE primarySurface #FFFFFF primaryColor primarySurface #FFFFFF #212121 primaryColor primarySurface #FFFFFF #212121 ThemeOverlay .MaterialComponents .Dark.ActionBar ThemeOverlay .MaterialComponents .ActionBar.Surface actionBarTheme colorControlNormal → android:textColorPrimary android:textColorPrimary → colorOnSurface : alpha 87% colorControlNormal → colorOnSurface : alpha 60% ThemeOverlay .AppCompat .Dark.ActionBar colorControlNormal → android:textColorPrimary ThemeOverlay .AppCompat .ActionBar colorControlNormal → android:textColorPrimary ThemeOverlay .AppCompat .ActionBar colorControlNormal → android:textColorPrimary ThemeOverlay .AppCompat .ActionBar colorControlNormal → android:textColorPrimary
Widget.MaterialComponents.ActionBar.Surface android:textColorPrimary Widget.MaterialComponents.ActionBar.Primary colorSurface : alpha 100% colorControlNormal android:textColorPrimary colorPrimary
: alpha 100% colorControlNormal Widget.MaterialComponents.ActionBar.Solid Widget.MaterialComponents.Light.ActionBar.Solid android:textColorPrimary colorPrimary : alpha 100% colorControlNormal android:textColorPrimary colorPrimary : alpha 100% colorControlNormal
Widget.MaterialComponents.ActionBar.Surface Widget.AppCompat.Light.ActionBar.Solid background → colorSurface : alpha 100% parent Widget.MaterialComponents.ActionBar.Primary
Widget.AppCompat.ActionBar.Solid background → colorPrimary : alpha 100% Widget.MaterialComponents.ActionBar.Solid Widget.MaterialComponents.Light.ActionBar.Solid background → colorPrimary : alpha 100% background → colorPrimary : alpha 100%