Skip to content

Commit

Permalink
Bug 1148670 - Correct onLayout calculation in MenuItemActionView. r=m…
Browse files Browse the repository at this point in the history
…haigh

--HG--
extra : rebase_source : b1187135037bee81ceb99e12a28cb983eb5626e9
  • Loading branch information
mcomella committed Mar 28, 2015
1 parent dca3593 commit 4458144
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mobile/android/base/menu/MenuItemActionView.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ public MenuItemActionView(Context context, AttributeSet attrs, int defStyle) {

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
View parent = (View) getParent();
final int padding = getPaddingLeft() + getPaddingRight();
final int width = right - left;

final View parent = (View) getParent();
final int parentPadding = parent.getPaddingLeft() + parent.getPaddingRight();
if ((right - left - padding) < (parent.getMeasuredWidth() - parentPadding) || mActionButtons.size() != 0) {
final int horizontalSpaceAvailableInParent = parent.getMeasuredWidth() - parentPadding;

// Check if there is another View sharing horizontal
// space with this View in the parent.
if (width < horizontalSpaceAvailableInParent || mActionButtons.size() != 0) {
// Use the icon.
mMenuItem.setVisibility(View.GONE);
mMenuButton.setVisibility(View.VISIBLE);
Expand Down

0 comments on commit 4458144

Please sign in to comment.