Skip to content

Commit 07c167b

Browse files
committed
set proper widget sizes, divide them by density
1 parent 464adc7 commit 07c167b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,15 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
465465
val widgetWidth = item.getWidthInCells() * cellWidth
466466
val widgetHeight = item.getHeightInCells() * cellHeight
467467

468+
val density = context.resources.displayMetrics.density
469+
val widgetDpWidth = (widgetWidth / density).toInt()
470+
val widgetDpHeight = (widgetHeight / density).toInt()
471+
468472
if (isSPlus()) {
469-
val sizes = listOf(SizeF(widgetWidth.toFloat(), widgetHeight.toFloat()))
473+
val sizes = listOf(SizeF(widgetDpWidth.toFloat(), widgetDpHeight.toFloat()))
470474
widgetView.updateAppWidgetSize(Bundle(), sizes)
471475
} else {
472-
widgetView.updateAppWidgetSize(Bundle(), widgetWidth, widgetHeight, widgetWidth, widgetHeight)
476+
widgetView.updateAppWidgetSize(Bundle(), widgetDpWidth, widgetDpHeight, widgetDpWidth, widgetDpHeight)
473477
}
474478

475479
widgetView.layoutParams?.width = widgetWidth

0 commit comments

Comments
 (0)