Use default item margin when no space for option peeking case
Screenshot for max display and font size: https://screenshot.googleplex.com/8hReLB6G4LUiL4c.png
Fixes: 189711388
Test: Manually
Change-Id: I91f94dc16a8e1d699e1e40e82487647c4fbd3ef6
diff --git a/src/com/android/customization/widget/OptionSelectorController.java b/src/com/android/customization/widget/OptionSelectorController.java
index 9ecc0d2..1c5c2a1 100644
--- a/src/com/android/customization/widget/OptionSelectorController.java
+++ b/src/com/android/customization/widget/OptionSelectorController.java
@@ -326,9 +326,13 @@
int spaceBetweenItems = availableWidth
- Math.round(widthPerItem * LINEAR_LAYOUT_HORIZONTAL_DISPLAY_OPTIONS_MAX)
- mContainer.getPaddingLeft();
- mContainer.addItemDecoration(new HorizontalBehindSpaceItemDecoration(
- mContainer.getContext(),
- spaceBetweenItems / (int) LINEAR_LAYOUT_HORIZONTAL_DISPLAY_OPTIONS_MAX));
+ int itemEndMargin =
+ spaceBetweenItems / (int) LINEAR_LAYOUT_HORIZONTAL_DISPLAY_OPTIONS_MAX;
+ if (itemEndMargin <= 0) {
+ itemEndMargin = res.getDimensionPixelOffset(R.dimen.option_tile_margin_horizontal);
+ }
+ mContainer.addItemDecoration(new ItemEndHorizontalSpaceItemDecoration(
+ mContainer.getContext(), itemEndMargin));
return;
}
@@ -437,12 +441,12 @@
}
/** Custom ItemDecorator to add specific spacing between items in the list. */
- private static final class HorizontalBehindSpaceItemDecoration
+ private static final class ItemEndHorizontalSpaceItemDecoration
extends RecyclerView.ItemDecoration {
private final int mHorizontalSpacePx;
private final boolean mDirectionLTR;
- private HorizontalBehindSpaceItemDecoration(Context context, int horizontalSpacePx) {
+ private ItemEndHorizontalSpaceItemDecoration(Context context, int horizontalSpacePx) {
mDirectionLTR = context.getResources().getConfiguration().getLayoutDirection()
== View.LAYOUT_DIRECTION_LTR;
mHorizontalSpacePx = horizontalSpacePx;