File tree Expand file tree Collapse file tree 7 files changed +26
-2
lines changed
lib/java/com/google/android/material
bottomnavigation/res/values Expand file tree Collapse file tree 7 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 3131 <item name =" itemActiveIndicatorStyle" >@null</item >
3232 <item name =" android:minHeight" >@dimen/design_bottom_navigation_height</item >
3333 <item name =" itemIconGravity" >top</item >
34+ <item name =" measureBottomPaddingFromLabelBaseline" >false</item >
3435 </style >
3536
3637 <!-- Default style for BottomNavigationViews.
Original file line number Diff line number Diff line change @@ -673,6 +673,8 @@ public void setIconSize(int iconSize) {
673673 // TODO(b/338647654): We can remove this once navigation rail is updated
674674 public void setMeasureBottomPaddingFromLabelBaseline (boolean measurePaddingFromBaseline ) {
675675 labelGroup .setMeasurePaddingFromBaseline (measurePaddingFromBaseline );
676+ smallLabel .setIncludeFontPadding (measurePaddingFromBaseline );
677+ largeLabel .setIncludeFontPadding (measurePaddingFromBaseline );
676678 requestLayout ();
677679 }
678680
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ public abstract class NavigationBarMenuView extends ViewGroup implements MenuVie
110110
111111 private NavigationBarPresenter presenter ;
112112 private MenuBuilder menu ;
113+ private boolean measurePaddingFromLabelBaseline ;
113114
114115 public NavigationBarMenuView (@ NonNull Context context ) {
115116 super (context );
@@ -369,6 +370,15 @@ public void setItemPaddingBottom(@Px int paddingBottom) {
369370 }
370371 }
371372
373+ public void setMeasurePaddingFromLabelBaseline (boolean measurePaddingFromLabelBaseline ) {
374+ this .measurePaddingFromLabelBaseline = measurePaddingFromLabelBaseline ;
375+ if (buttons != null ) {
376+ for (NavigationBarItemView item : buttons ) {
377+ item .setMeasureBottomPaddingFromLabelBaseline (measurePaddingFromLabelBaseline );
378+ }
379+ }
380+ }
381+
372382 /**
373383 * Get the distance between the item's active indicator container and the label.
374384 */
@@ -778,6 +788,7 @@ public void buildMenuView() {
778788 if (itemPaddingBottom != NO_PADDING ) {
779789 child .setItemPaddingBottom (itemPaddingBottom );
780790 }
791+ child .setMeasureBottomPaddingFromLabelBaseline (measurePaddingFromLabelBaseline );
781792 if (itemActiveIndicatorLabelPadding != NO_PADDING ) {
782793 child .setActiveIndicatorLabelPadding (itemActiveIndicatorLabelPadding );
783794 }
Original file line number Diff line number Diff line change @@ -278,6 +278,9 @@ public NavigationBarView(
278278 context , attributes , R .styleable .NavigationBarView_itemRippleColor ));
279279 }
280280
281+ setMeasureBottomPaddingFromLabelBaseline (attributes .getBoolean (
282+ R .styleable .NavigationBarView_measureBottomPaddingFromLabelBaseline , true ));
283+
281284 int activeIndicatorStyleResId =
282285 attributes .getResourceId (R .styleable .NavigationBarView_itemActiveIndicatorStyle , 0 );
283286
@@ -605,6 +608,10 @@ public void setItemPaddingBottom(@Px int paddingBottom) {
605608 menuView .setItemPaddingBottom (paddingBottom );
606609 }
607610
611+ private void setMeasureBottomPaddingFromLabelBaseline (boolean measurePaddingFromBaseline ) {
612+ menuView .setMeasurePaddingFromLabelBaseline (measurePaddingFromBaseline );
613+ }
614+
608615 /**
609616 * Set the distance between the active indicator container and the item's label.
610617 */
Original file line number Diff line number Diff line change 8787 <enum name =" top" value =" 0" />
8888 <enum name =" start" value =" 1" />
8989 </attr >
90+
91+ <!-- Measure the item's bottom padding from the baseline of the label, not the bottom of its
92+ view. -->
93+ <attr name =" measureBottomPaddingFromLabelBaseline" format =" boolean" />
9094 </declare-styleable >
9195
9296 <declare-styleable name =" NavigationBarActiveIndicator" >
Original file line number Diff line number Diff line change 3333final class NavigationRailItemView extends NavigationBarItemView {
3434 public NavigationRailItemView (@ NonNull Context context ) {
3535 super (context );
36- // TODO(b/338647654): Measure Navigation Rail from the bottom of the textview, not baseline
37- setMeasureBottomPaddingFromLabelBaseline (true );
3836 }
3937
4038 @ Override
Original file line number Diff line number Diff line change 4242 <item name =" contentMarginTop" >@dimen/mtrl_navigation_rail_margin</item >
4343 <item name =" headerMarginBottom" >@dimen/mtrl_navigation_rail_margin</item >
4444 <item name =" itemIconGravity" >top</item >
45+ <item name =" measureBottomPaddingFromLabelBaseline" >true</item >
4546 </style >
4647
4748 <style name =" Widget.MaterialComponents.NavigationRailView.Compact" >
You can’t perform that action at this time.
0 commit comments