Merge "Fix width of GA popup menu." into rvc-dev am: c4452824a0 am: b1809e1c32

Change-Id: I8f9fb8863927a8398b51c75814aee5209f8f593a
This commit is contained in:
Fabian Kozynski
2020-05-21 16:22:41 +00:00
committed by Automerger Merge Worker

View File

@@ -89,15 +89,19 @@ public class GlobalActionsPopupMenu extends ListPopupWindow {
// width should be between [.5, .9] of screen
int parentWidth = res.getSystem().getDisplayMetrics().widthPixels;
int widthSpec = MeasureSpec.makeMeasureSpec(
(int) (parentWidth * 0.9), MeasureSpec.AT_MOST);
View child = mAdapter.getView(0, null, listView);
child.measure(widthSpec, MeasureSpec.UNSPECIFIED);
int width = Math.max(child.getMeasuredWidth(), (int) (parentWidth * 0.5));
(int) (parentWidth * 0.9) - 2 * mMenuHorizontalPadding, MeasureSpec.AT_MOST);
int maxWidth = 0;
for (int i = 0; i < mAdapter.getCount(); i++) {
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,
mMenuHorizontalPadding, mMenuVerticalPadding);
setWidth(width);
setWidth(width + 2 * mMenuHorizontalPadding);
setHorizontalOffset(getAnchorView().getWidth() - mGlobalActionsSidePadding - width);
}