For #15757 - Avoid the double spacing issues for grid items in tabs tray
Items should have a 16dp all around padding. Have them have a 8dp padding that will add to 16 when placed together. Have the parent have another 8dp that will add to 16 for when items are placed to the edge of the available screen.
This commit is contained in:
parent
0324baef03
commit
83bd80c873
|
@ -44,6 +44,7 @@ import mozilla.components.browser.state.state.TabSessionState
|
|||
import mozilla.components.browser.tabstray.TabViewHolder
|
||||
import mozilla.components.feature.syncedtabs.SyncedTabsFeature
|
||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||
import mozilla.components.support.ktx.android.util.dpToPx
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.browser.InfoBanner
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
|
@ -399,6 +400,15 @@ class TabTrayView(
|
|||
}
|
||||
|
||||
layoutManager = gridLayoutManager
|
||||
|
||||
// Ensure items have the same all around padding - 16 dp. Avoid the double spacing issue.
|
||||
// A 8dp padding is already set in xml, pad the parent with the remaining needed 8dp.
|
||||
updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||
val padding = GRID_ITEM_PARENT_PADDING.dpToPx(resources.displayMetrics)
|
||||
// Account for the already set bottom padding needed to accommodate the fab.
|
||||
val bottomPadding = paddingBottom + padding
|
||||
setPadding(padding, padding, padding, bottomPadding)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -702,6 +712,8 @@ class TabTrayView(
|
|||
private const val SELECTION_DELAY = 500
|
||||
private const val NORMAL_HANDLE_PERCENT_WIDTH = 0.1F
|
||||
private const val COLUMN_WIDTH_DP = 180
|
||||
// The remaining padding offset needed to provide a 16dp column spacing between the grid items.
|
||||
const val GRID_ITEM_PARENT_PADDING = 8
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -181,6 +181,7 @@
|
|||
android:layout_height="0dp"
|
||||
android:clipToPadding="false"
|
||||
android:paddingBottom="140dp"
|
||||
android:scrollbarStyle="outsideOverlay"
|
||||
android:scrollbars="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
Loading…
Reference in New Issue
Block a user