Merge "Fix width of GA popup menu." into rvc-dev am: c4452824a0 am: b1809e1c32
Change-Id: I8f9fb8863927a8398b51c75814aee5209f8f593a
This commit is contained in:
@@ -89,15 +89,19 @@ public class GlobalActionsPopupMenu extends ListPopupWindow {
|
|||||||
// width should be between [.5, .9] of screen
|
// width should be between [.5, .9] of screen
|
||||||
int parentWidth = res.getSystem().getDisplayMetrics().widthPixels;
|
int parentWidth = res.getSystem().getDisplayMetrics().widthPixels;
|
||||||
int widthSpec = MeasureSpec.makeMeasureSpec(
|
int widthSpec = MeasureSpec.makeMeasureSpec(
|
||||||
(int) (parentWidth * 0.9), MeasureSpec.AT_MOST);
|
(int) (parentWidth * 0.9) - 2 * mMenuHorizontalPadding, MeasureSpec.AT_MOST);
|
||||||
View child = mAdapter.getView(0, null, listView);
|
int maxWidth = 0;
|
||||||
child.measure(widthSpec, MeasureSpec.UNSPECIFIED);
|
for (int i = 0; i < mAdapter.getCount(); i++) {
|
||||||
int width = Math.max(child.getMeasuredWidth(), (int) (parentWidth * 0.5));
|
View child = mAdapter.getView(i, null, listView);
|
||||||
|
child.measure(widthSpec, MeasureSpec.UNSPECIFIED);
|
||||||
|
int w = child.getMeasuredWidth();
|
||||||
|
maxWidth = Math.max(w, maxWidth);
|
||||||
|
}
|
||||||
|
int width = Math.max(maxWidth, (int) (parentWidth * 0.5) - 2 * mMenuHorizontalPadding);
|
||||||
listView.setPadding(mMenuHorizontalPadding, mMenuVerticalPadding,
|
listView.setPadding(mMenuHorizontalPadding, mMenuVerticalPadding,
|
||||||
mMenuHorizontalPadding, mMenuVerticalPadding);
|
mMenuHorizontalPadding, mMenuVerticalPadding);
|
||||||
|
|
||||||
setWidth(width);
|
setWidth(width + 2 * mMenuHorizontalPadding);
|
||||||
setHorizontalOffset(getAnchorView().getWidth() - mGlobalActionsSidePadding - width);
|
setHorizontalOffset(getAnchorView().getWidth() - mGlobalActionsSidePadding - width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user