Commit eba63433 authored by Amirhossein Simjour's avatar Amirhossein Simjour Committed by Commit Bot

Fix the size of the Autofill popups

The width of the DropdownPopupWindow is updated to match its
AnchoredView. Moreover, the DropdownPopupWindow will be aligned to
the center of the AnchoredView.

BUG=820886

Change-Id: Ia82bd5a78c1e2ab4f1e68aecfa38fa219751de36
Reviewed-on: https://chromium-review.googlesource.com/960568Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Amirhossein Simjour <asimjour@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543614}
parent 150adef2
...@@ -34,6 +34,7 @@ public class DropdownPopupWindow implements AnchoredPopupWindow.LayoutObserver { ...@@ -34,6 +34,7 @@ public class DropdownPopupWindow implements AnchoredPopupWindow.LayoutObserver {
ListAdapter mAdapter; ListAdapter mAdapter;
private ListView mListView; private ListView mListView;
private Drawable mBackground; private Drawable mBackground;
private int mHorizontalPadding;
/** /**
* Creates an DropdownPopupWindow with specified parameters. * Creates an DropdownPopupWindow with specified parameters.
...@@ -75,6 +76,12 @@ public class DropdownPopupWindow implements AnchoredPopupWindow.LayoutObserver { ...@@ -75,6 +76,12 @@ public class DropdownPopupWindow implements AnchoredPopupWindow.LayoutObserver {
new AnchoredPopupWindow(context, mAnchorView, mBackground, mListView, rectProvider); new AnchoredPopupWindow(context, mAnchorView, mBackground, mListView, rectProvider);
mAnchoredPopupWindow.addOnDismissListener(onDismissLitener); mAnchoredPopupWindow.addOnDismissListener(onDismissLitener);
mAnchoredPopupWindow.setLayoutObserver(this); mAnchoredPopupWindow.setLayoutObserver(this);
Rect paddingRect = new Rect();
mBackground.getPadding(paddingRect);
rectProvider.setInsetPx(0, /* top= */ paddingRect.bottom, 0, /* bottom= */ paddingRect.top);
mHorizontalPadding = paddingRect.right + paddingRect.left;
mAnchoredPopupWindow.setPreferredHorizontalOrientation(
AnchoredPopupWindow.HORIZONTAL_ORIENTATION_CENTER);
} }
/** /**
...@@ -112,9 +119,12 @@ public class DropdownPopupWindow implements AnchoredPopupWindow.LayoutObserver { ...@@ -112,9 +119,12 @@ public class DropdownPopupWindow implements AnchoredPopupWindow.LayoutObserver {
boolean wasShowing = mAnchoredPopupWindow.isShowing(); boolean wasShowing = mAnchoredPopupWindow.isShowing();
mAnchoredPopupWindow.setVerticalOverlapAnchor(false); mAnchoredPopupWindow.setVerticalOverlapAnchor(false);
mAnchoredPopupWindow.setHorizontalOverlapAnchor(true); mAnchoredPopupWindow.setHorizontalOverlapAnchor(true);
mAnchoredPopupWindow.setMaxWidth(measureContentWidth() int contentWidth = measureContentWidth();
+ mContext.getResources().getDimensionPixelSize( if (mAnchorView.getWidth() < contentWidth) {
R.dimen.dropdown_item_label_margin)); mAnchoredPopupWindow.setMaxWidth(contentWidth + mHorizontalPadding);
} else {
mAnchoredPopupWindow.setMaxWidth(mAnchorView.getWidth() + mHorizontalPadding);
}
mAnchoredPopupWindow.show(); mAnchoredPopupWindow.show();
mListView.setDividerHeight(0); mListView.setDividerHeight(0);
ApiCompatibilityUtils.setLayoutDirection( ApiCompatibilityUtils.setLayoutDirection(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment