List of usage examples for android.widget ActionMenuView generateOverflowButtonLayoutParams
public LayoutParams generateOverflowButtonLayoutParams()
From source file:lewa.support.v7.internal.view.menu.ActionMenuPresenter.java
@Override public void updateMenuView(boolean cleared) { super.updateMenuView(cleared); if (mMenuView == null) { return;//from w ww . j a va 2 s . c om } if (mMenu != null) { final ArrayList<MenuItemImpl> actionItems = mMenu.getActionItems(); final int count = actionItems.size(); for (int i = 0; i < count; i++) { final ActionProvider provider = actionItems.get(i).getSupportActionProvider(); if (provider != null) { provider.setSubUiVisibilityListener(this); } } } final ArrayList<MenuItemImpl> nonActionItems = mMenu != null ? mMenu.getNonActionItems() : null; boolean hasOverflow = false; if (mReserveOverflow && nonActionItems != null) { final int count = nonActionItems.size(); if (count == 1) { hasOverflow = !nonActionItems.get(0).isActionViewExpanded(); } else { hasOverflow = count > 0; } } if (hasOverflow) { if (mOverflowButton == null) { mOverflowButton = new OverflowMenuButton(mSystemContext); } ViewGroup parent = (ViewGroup) mOverflowButton.getParent(); if (parent != mMenuView) { if (parent != null) { parent.removeView(mOverflowButton); } ActionMenuView menuView = (ActionMenuView) mMenuView; menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams()); } } else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) { ((ViewGroup) mMenuView).removeView(mOverflowButton); } ((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow); }