Fix widget span

Need to take the horizontal margin of the view into consideration.

Fix: 233302799
Test: manual
Change-Id: I5f584977db85d5436b22c3701f586a5b079099ae
This commit is contained in:
Thales Lima
2022-05-24 14:49:26 +01:00
parent 2940565595
commit 4f3cf5d05f

View File

@@ -198,7 +198,9 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView<Launcher>
/** Returns the number of cells that can fit horizontally in a given {@code content}. */
protected int computeMaxHorizontalSpans(View content, int contentHorizontalPaddingPx) {
DeviceProfile deviceProfile = mActivityContext.getDeviceProfile();
int availableWidth = content.getMeasuredWidth() - contentHorizontalPaddingPx;
int availableWidth = content.getMeasuredWidth()
- contentHorizontalPaddingPx
- (2 * mContentHorizontalMarginInPx);
Point cellSize = deviceProfile.getCellSize();
if (cellSize.x > 0) {
return availableWidth / cellSize.x;