Skip to content

Commit

Permalink
Check menu item visibility when calculating menu size.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-signal authored and greyson-signal committed Apr 21, 2020
1 parent c6dd25a commit 2d60d5f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}

public static void adjustMenuActions(@NonNull Menu menu, int maxToShow, int toolbarWidthPx) {
int menuSize = menu.size();
int menuSize = 0;

for (int i = 0; i < menu.size(); i++) {
if (menu.getItem(i).isVisible()) {
menuSize++;
}
}

int widthAllowed = toolbarWidthPx - ViewUtil.dpToPx(NAVIGATION_DP);
int nItemsToShow = Math.min(maxToShow, widthAllowed / ViewUtil.dpToPx(ACTION_VIEW_WIDTH_DP));
Expand Down

0 comments on commit 2d60d5f

Please sign in to comment.