Skip to content

Commit 12fad1d

Browse files
imhappileticiarossi
authored andcommitted
[NavigationRail] Force NavigationFrameLayout to be the available size at the minimum
PiperOrigin-RevId: 753364953
1 parent 4070bef commit 12fad1d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/java/com/google/android/material/navigationrail/NavigationRailFrameLayout.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
5555
int totalHeaderHeight = 0;
5656
View menuView = getChildAt(0);
5757
int menuHeightSpec = heightMeasureSpec;
58+
int height = MeasureSpec.getSize(heightMeasureSpec);
5859

5960
// If there's more than one child, the header should be first
6061
if (childCount > 1) {
@@ -64,7 +65,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
6465
LayoutParams headerLp = (LayoutParams) headerView.getLayoutParams();
6566
totalHeaderHeight =
6667
headerView.getMeasuredHeight() + headerLp.bottomMargin + headerLp.topMargin;
67-
int maxMenuHeight = getMeasuredHeight() - totalHeaderHeight - paddingTop;
68+
int maxMenuHeight = height - totalHeaderHeight - paddingTop;
6869

6970
// Measure menu
7071
menuView = getChildAt(1);
@@ -77,7 +78,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
7778
LayoutParams menuLp = (LayoutParams) menuView.getLayoutParams();
7879
measureChild(menuView, widthMeasureSpec, menuHeightSpec);
7980
int totalMenuHeight = menuView.getMeasuredHeight() + menuLp.bottomMargin + menuLp.topMargin;
80-
int totalHeight = max(getMeasuredHeight(), paddingTop + totalHeaderHeight + totalMenuHeight);
81+
int totalHeight = max(height, paddingTop + totalHeaderHeight + totalMenuHeight);
8182

8283
setMeasuredDimension(getMeasuredWidth(), totalHeight);
8384
}

0 commit comments

Comments
 (0)