Skip to content

Commit e980f60

Browse files
pekingmeleticiarossi
authored andcommitted
[BottomNav] Added Expressive styles.
PiperOrigin-RevId: 749114894
1 parent 02fcdf5 commit e980f60

File tree

8 files changed

+173
-2
lines changed

8 files changed

+173
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 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+
~ https://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+
<!-- Active item -->
19+
<item android:color="@macro/m3_comp_nav_bar_item_active_icon_color"
20+
android:state_checked="true"/>
21+
22+
<!-- Inactive item -->
23+
<item android:color="@macro/m3_comp_nav_bar_item_inactive_icon_color"/>
24+
</selector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 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+
~ https://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+
<!-- Active item -->
19+
<item android:color="@macro/m3_comp_nav_bar_item_active_label_text_color"
20+
android:state_checked="true"/>
21+
22+
<!-- Inactive item -->
23+
<item android:color="@macro/m3_comp_nav_bar_item_inactive_label_text_color"/>
24+
</selector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 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+
~ https://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+
19+
<!-- Selected. -->
20+
<item android:alpha="@dimen/m3_ripple_pressed_alpha"
21+
android:color="@macro/m3_comp_nav_bar_item_active_pressed_state_layer_color"
22+
android:state_pressed="true" android:state_selected="true"/>
23+
<item android:alpha="@dimen/m3_ripple_focused_alpha"
24+
android:color="@macro/m3_comp_nav_bar_item_active_focused_state_layer_color"
25+
android:state_focused="true" android:state_selected="true"/>
26+
<item android:alpha="@dimen/m3_ripple_hovered_alpha"
27+
android:color="@macro/m3_comp_nav_bar_item_active_hovered_state_layer_color"
28+
android:state_hovered="true" android:state_selected="true"/>
29+
30+
<!-- Unselected. -->
31+
<item android:alpha="@dimen/m3_ripple_pressed_alpha"
32+
android:color="@macro/m3_comp_nav_bar_item_inactive_pressed_state_layer_color"
33+
android:state_pressed="true"/>
34+
<item android:alpha="@dimen/m3_ripple_focused_alpha"
35+
android:color="@macro/m3_comp_nav_bar_item_inactive_focused_state_layer_color"
36+
android:state_focused="true"/>
37+
<item android:alpha="@dimen/m3_ripple_hovered_alpha"
38+
android:color="@macro/m3_comp_nav_bar_item_inactive_hovered_state_layer_color"
39+
android:state_hovered="true"/>
40+
<item android:color="@android:color/transparent"/>
41+
</selector>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 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+
~ https://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+
<integer name="m3expressive_bottom_nav_icon_gravity">1</integer>
19+
<integer name="m3expressive_bottom_nav_item_gravity">17</integer>
20+
</resources>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 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+
~ https://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+
<integer name="m3expressive_bottom_nav_icon_gravity">0</integer>
19+
<integer name="m3expressive_bottom_nav_item_gravity">49</integer>
20+
</resources>

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,40 @@
1616
-->
1717
<resources>
1818

19+
<!-- Styles for M3 Expressive BottomNavigationView. -->
20+
21+
<style name="Widget.Material3Expressive.BottomNavigationView" parent="Widget.Material3.BottomNavigationView">
22+
<item name="android:minHeight">@dimen/m3_comp_nav_bar_container_height</item>
23+
<item name="elevation">@dimen/m3_comp_nav_bar_container_elevation</item>
24+
<item name="android:background">@macro/m3_comp_nav_bar_container_color</item>
25+
<item name="itemTextColor">@color/m3expressive_bottom_nav_item_label_tint</item>
26+
<item name="itemIconTint">@color/m3expressive_bottom_nav_item_icon_tint</item>
27+
<item name="itemRippleColor">@color/m3expressive_bottom_nav_item_ripple_tint</item>
28+
<item name="itemPaddingTop">@dimen/m3_comp_nav_bar_item_vertical_container_between_space</item>
29+
<item name="itemPaddingBottom">@dimen/m3_comp_nav_bar_item_vertical_container_between_space</item>
30+
<item name="itemIconGravity">@integer/m3expressive_bottom_nav_icon_gravity</item>
31+
<item name="itemGravity">@integer/m3expressive_bottom_nav_item_gravity</item>
32+
<item name="itemTextAppearanceActiveBoldEnabled">false</item>
33+
<item name="itemTextAppearanceActive">@macro/m3_comp_nav_bar_item_vertical_label_text_font</item>
34+
<item name="itemTextAppearanceInactive">@macro/m3_comp_nav_bar_item_vertical_label_text_font</item>
35+
<item name="horizontalItemTextAppearanceActive">@macro/m3_comp_nav_bar_item_horizontal_label_text_font</item>
36+
<item name="horizontalItemTextAppearanceInactive">@macro/m3_comp_nav_bar_item_horizontal_label_text_font</item>
37+
<item name="itemActiveIndicatorStyle">@style/Widget.Material3Expressive.BottomNavigationView.ActiveIndicator</item>
38+
<item name="activeIndicatorLabelPadding">@dimen/m3_comp_nav_bar_item_active_indicator_icon_label_space</item>
39+
<item name="itemIconSize">@dimen/m3_comp_nav_bar_item_icon_size</item>
40+
<item name="labelFontScalingEnabled">true</item>
41+
<item name="labelMaxLines">999</item>
42+
</style>
43+
44+
<style name="Widget.Material3Expressive.BottomNavigationView.ActiveIndicator" parent="Widget.Material3.BottomNavigationView.ActiveIndicator">
45+
<item name="android:width">@dimen/m3_comp_nav_bar_item_vertical_active_indicator_width</item>
46+
<item name="android:height">@dimen/m3_comp_nav_bar_item_vertical_active_indicator_height</item>
47+
<item name="marginHorizontal">@dimen/m3_bottom_nav_item_active_indicator_margin_horizontal</item>
48+
<item name="shapeAppearance">@style/ShapeAppearance.M3.Comp.NavBar.Item.ActiveIndicator.Shape</item>
49+
<item name="android:color">@macro/m3_comp_nav_bar_item_active_indicator_color</item>
50+
<item name="expandedHeight">@dimen/m3_comp_nav_bar_item_horizontal_active_indicator_height</item>
51+
</style>
52+
1953
<!-- Styles for M3 BottomNavigationView. -->
2054

2155
<style name="Base.Widget.Material3.BottomNavigationView" parent="Widget.MaterialComponents.BottomNavigationView">

lib/java/com/google/android/material/dialog/res/values/themes_base.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
<item name="toolbarStyle">@style/Widget.Material3Expressive.Toolbar</item>
6868
<item name="toolbarSurfaceStyle">@style/Widget.Material3Expressive.Toolbar.Surface</item>
6969

70+
<item name="bottomNavigationStyle">@style/Widget.Material3Expressive.BottomNavigationView</item>
71+
7072
<!-- Top App Bars. -->
7173
<item name="collapsingToolbarLayoutMediumSize">@dimen/m3_comp_app_bar_medium_flexible_container_height</item>
7274
<item name="collapsingToolbarLayoutLargeSize">@dimen/m3_comp_app_bar_large_flexible_container_height</item>
@@ -115,6 +117,8 @@
115117
<item name="toolbarStyle">@style/Widget.Material3Expressive.Toolbar</item>
116118
<item name="toolbarSurfaceStyle">@style/Widget.Material3Expressive.Toolbar.Surface</item>
117119

120+
<item name="bottomNavigationStyle">@style/Widget.Material3Expressive.BottomNavigationView</item>
121+
118122
<!-- Top App Bars. -->
119123
<item name="collapsingToolbarLayoutMediumSize">@dimen/m3_comp_app_bar_medium_flexible_container_height</item>
120124
<item name="collapsingToolbarLayoutLargeSize">@dimen/m3_comp_app_bar_large_flexible_container_height</item>

lib/java/com/google/android/material/theme/res/values/themes_base.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@
6565
<item name="materialIconButtonFilledStyle">@style/Widget.Material3Expressive.Button.IconButton.Filled</item>
6666
<item name="materialIconButtonFilledTonalStyle">@style/Widget.Material3Expressive.Button.IconButton.Tonal</item>
6767

68+
<item name="materialButtonGroupStyle">@style/Widget.Material3Expressive.MaterialButtonGroup</item>
69+
<item name="materialButtonToggleGroupStyle">@style/Widget.Material3Expressive.MaterialButtonToggleGroup</item>
70+
6871
<item name="toolbarStyle">@style/Widget.Material3Expressive.Toolbar</item>
6972
<item name="toolbarSurfaceStyle">@style/Widget.Material3Expressive.Toolbar.Surface</item>
7073

71-
<item name="materialButtonGroupStyle">@style/Widget.Material3Expressive.MaterialButtonGroup</item>
72-
<item name="materialButtonToggleGroupStyle">@style/Widget.Material3Expressive.MaterialButtonToggleGroup</item>
74+
<item name="bottomNavigationStyle">@style/Widget.Material3Expressive.BottomNavigationView</item>
7375

7476
<!-- Top App Bars. -->
7577
<item name="collapsingToolbarLayoutMediumSize">@dimen/m3_comp_app_bar_medium_flexible_container_height</item>
@@ -126,6 +128,8 @@
126128
<item name="toolbarStyle">@style/Widget.Material3Expressive.Toolbar</item>
127129
<item name="toolbarSurfaceStyle">@style/Widget.Material3Expressive.Toolbar.Surface</item>
128130

131+
<item name="bottomNavigationStyle">@style/Widget.Material3Expressive.BottomNavigationView</item>
132+
129133
<!-- Top App Bars. -->
130134
<item name="collapsingToolbarLayoutMediumSize">@dimen/m3_comp_app_bar_medium_flexible_container_height</item>
131135
<item name="collapsingToolbarLayoutLargeSize">@dimen/m3_comp_app_bar_large_flexible_container_height</item>

0 commit comments

Comments
 (0)