Skip to content

Commit 3b971c9

Browse files
pekingmeimhappi
authored andcommitted
[TopAppBar] Updated ripple color on actions in M3 toolbar.
PiperOrigin-RevId: 826228085
1 parent dc98ca0 commit 3b971c9

File tree

10 files changed

+184
-1
lines changed

10 files changed

+184
-1
lines changed

lib/java/com/google/android/material/appbar/res/values/styles.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
<item name="contentInsetStartWithNavigation">0dp</item>
129129
<item name="android:keyboardNavigationCluster" tools:targetApi="o">false</item>
130130
<item name="android:touchscreenBlocksFocus">false</item>
131+
<item name="materialThemeOverlay">@style/ThemeOverlay.Material3.Toolbar</item>
131132

132133
<!-- On newer API levels, hide shadows while keeping elevation. -->
133134
<item name="android:outlineAmbientShadowColor" tools:targetApi="p">@android:color/transparent</item>
@@ -151,7 +152,18 @@
151152
<item name="android:background">@macro/m3_comp_app_bar_container_color</item>
152153
</style>
153154

154-
<style name="ThemeOverlay.Material3.Toolbar.Surface" parent="">
155+
<style name="ThemeOverlay.Material3.Toolbar" parent="">
156+
<!-- Overridding the AppCompat / Android drawable attributes for correct ripple colors. -->
157+
<item name="selectableItemBackground">@drawable/m3_selectable_item_background</item>
158+
<item name="android:selectableItemBackground">@drawable/m3_selectable_item_background</item>
159+
<item name="selectableItemBackgroundBorderless">@drawable/m3_selectable_item_background_borderless</item>
160+
<item name="android:selectableItemBackgroundBorderless">@drawable/m3_selectable_item_background_borderless</item>
161+
<item name="actionBarItemBackground">@drawable/m3_action_bar_item_background</item>
162+
<item name="android:actionBarItemBackground">@drawable/m3_action_bar_item_background</item>
163+
<item name="controlBackground">@drawable/m3_action_bar_item_background</item>
164+
</style>
165+
166+
<style name="ThemeOverlay.Material3.Toolbar.Surface">
155167
<item name="actionMenuTextColor">@macro/m3_comp_app_bar_trailing_icon_color</item>
156168
<item name="colorControlNormal">@macro/m3_comp_app_bar_trailing_icon_color</item>
157169
</style>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2025 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
18+
<item android:alpha="@dimen/m3_control_ripple_color_selector_pressed_alpha" android:color="?attr/colorOnSurfaceVariant" android:state_pressed="true"/>
19+
<item android:alpha="@dimen/m3_control_ripple_color_selector_focused_alpha" android:color="?attr/colorOnSurfaceVariant" android:state_focused="true"/>
20+
<item android:alpha="@dimen/m3_control_ripple_color_selector_hovered_alpha" android:color="?attr/colorOnSurfaceVariant" android:state_hovered="true"/>
21+
<item android:alpha="@dimen/m3_control_ripple_color_selector_default_alpha" android:color="?attr/colorOnSurfaceVariant"/>
22+
</selector>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2025 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:color="@color/m3_control_ripple_color_selector"
19+
android:radius="20dp"/>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2025 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:color="@color/m3_control_ripple_color_selector">
19+
<item android:id="@android:id/mask">
20+
<color android:color="@android:color/white" />
21+
</item>
22+
</ripple>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2025 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:color="@color/m3_control_ripple_color_selector"/>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2025 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<resources>
18+
<item name="m3_control_ripple_color_selector_focused_alpha" format="float" type="dimen">0.17</item>
19+
</resources>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2025 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<resources>
18+
<item name="m3_control_ripple_color_selector_pressed_alpha" format="float" type="dimen">0.12</item>
19+
<item name="m3_control_ripple_color_selector_hovered_alpha" format="float" type="dimen">0.1</item>
20+
<item name="m3_control_ripple_color_selector_default_alpha" format="float" type="dimen">0.2</item>
21+
</resources>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2025 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<resources>
18+
<item name="m3_control_ripple_color_selector_pressed_alpha" format="float" type="dimen">0.36</item>
19+
<item name="m3_control_ripple_color_selector_focused_alpha" format="float" type="dimen">0.16</item>
20+
<item name="m3_control_ripple_color_selector_hovered_alpha" format="float" type="dimen">0.3</item>
21+
<item name="m3_control_ripple_color_selector_default_alpha" format="float" type="dimen">0.45</item>
22+
</resources>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2025 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<resources>
18+
<item name="m3_control_ripple_color_selector_pressed_alpha" format="float" type="dimen">0.12</item>
19+
<item name="m3_control_ripple_color_selector_focused_alpha" format="float" type="dimen">0.17</item>
20+
<item name="m3_control_ripple_color_selector_hovered_alpha" format="float" type="dimen">0.1</item>
21+
<item name="m3_control_ripple_color_selector_default_alpha" format="float" type="dimen">0.2</item>
22+
</resources>

lib/java/com/google/android/material/color/res/values/dimens.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,10 @@
2323
<item name="material_emphasis_disabled" format="float" type="dimen">0.38</item>
2424
<!-- Disabled emphasis of 12% for background containers. -->
2525
<item name="material_emphasis_disabled_background" format="float" type="dimen">0.12</item>
26+
27+
<!-- Default values for the control ripple color selector. -->
28+
<item name="m3_control_ripple_color_selector_pressed_alpha" format="float" type="dimen">0.1</item>
29+
<item name="m3_control_ripple_color_selector_focused_alpha" format="float" type="dimen">0.20</item>
30+
<item name="m3_control_ripple_color_selector_hovered_alpha" format="float" type="dimen">0.08</item>
31+
<item name="m3_control_ripple_color_selector_default_alpha" format="float" type="dimen">0.16</item>
2632
</resources>

0 commit comments

Comments
 (0)